mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Rebase to latest DB version and upgrade to Crystal 0.18
This commit is contained in:
parent
7fcedc6711
commit
552b6e12b4
6 changed files with 48 additions and 9 deletions
|
@ -57,7 +57,7 @@ module DB
|
|||
# This macro also declares instance variables of the types given in the mapping.
|
||||
macro mapping(properties, strict = true)
|
||||
{% for key, value in properties %}
|
||||
{% properties[key] = {type: value} unless value.is_a?(HashLiteral) %}
|
||||
{% properties[key] = {type: value} unless value.is_a?(HashLiteral) || value.is_a?(NamedTupleLiteral) %}
|
||||
{% end %}
|
||||
|
||||
{% for key, value in properties %}
|
||||
|
@ -86,7 +86,7 @@ module DB
|
|||
%found{key.id} = false
|
||||
{% end %}
|
||||
|
||||
%rs.each_column do |col_name, col_type|
|
||||
%rs.each_column do |col_name|
|
||||
case col_name
|
||||
{% for key, value in properties %}
|
||||
when {{value[:key] || key.id.stringify}}
|
||||
|
@ -95,7 +95,7 @@ module DB
|
|||
{% if value[:converter] %}
|
||||
{{value[:converter]}}.from_rs(%rs)
|
||||
{% elsif value[:nilable] || value[:default] != nil %}
|
||||
%rs.read?({{value[:type]}})
|
||||
%rs.read(Union({{value[:type]}} | Nil))
|
||||
{% else %}
|
||||
%rs.read({{value[:type]}})
|
||||
{% end %}
|
||||
|
@ -104,8 +104,7 @@ module DB
|
|||
{% if strict %}
|
||||
raise DB::MappingException.new("unknown result set attribute: #{col_name}")
|
||||
{% else %}
|
||||
# TODO: col_type can be Nil, and read?(Nil) is undefined; how to skip a column?
|
||||
#%rs.read?(col_type)
|
||||
%rs.read(Nil)
|
||||
{% end %}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ module DB
|
|||
# Iterates over all the columns
|
||||
def each_column
|
||||
column_count.times do |x|
|
||||
yield column_name(x), column_type(x)
|
||||
yield column_name(x)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue