mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Fixed module reference inside macro
This commit is contained in:
parent
ae6a68f00e
commit
4f724475e0
2 changed files with 6 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
name: db
|
||||
version: 0.1.0
|
||||
version: 0.1.1
|
||||
|
||||
authors:
|
||||
- Brian J. Cardiff <bcardiff@manas.com.ar>
|
||||
|
|
|
@ -58,7 +58,7 @@ module DB
|
|||
#
|
||||
# This macro also declares instance variables of the types given in the mapping.
|
||||
macro mapping(properties, strict = true)
|
||||
include DB::Mappable
|
||||
include ::DB::Mappable
|
||||
|
||||
{% for key, value in properties %}
|
||||
{% properties[key] = {type: value} unless value.is_a?(HashLiteral) || value.is_a?(NamedTupleLiteral) %}
|
||||
|
@ -76,7 +76,7 @@ module DB
|
|||
end
|
||||
{% end %}
|
||||
|
||||
def self.from_rs(%rs : DB::ResultSet)
|
||||
def self.from_rs(%rs : ::DB::ResultSet)
|
||||
%objs = Array(self).new
|
||||
%rs.each do
|
||||
%objs << self.new(%rs)
|
||||
|
@ -84,7 +84,7 @@ module DB
|
|||
%objs
|
||||
end
|
||||
|
||||
def initialize(%rs : DB::ResultSet)
|
||||
def initialize(%rs : ::DB::ResultSet)
|
||||
{% for key, value in properties %}
|
||||
%var{key.id} = nil
|
||||
%found{key.id} = false
|
||||
|
@ -106,7 +106,7 @@ module DB
|
|||
{% end %}
|
||||
else
|
||||
{% if strict %}
|
||||
raise DB::MappingException.new("unknown result set attribute: #{col_name}")
|
||||
raise ::DB::MappingException.new("unknown result set attribute: #{col_name}")
|
||||
{% else %}
|
||||
%rs.read
|
||||
{% end %}
|
||||
|
@ -116,7 +116,7 @@ module DB
|
|||
{% for key, value in properties %}
|
||||
{% unless value[:nilable] || value[:default] != nil %}
|
||||
if %var{key.id}.is_a?(Nil) && !%found{key.id}
|
||||
raise DB::MappingException.new("missing result set attribute: {{(value[:key] || key).id}}")
|
||||
raise ::DB::MappingException.new("missing result set attribute: {{(value[:key] || key).id}}")
|
||||
end
|
||||
{% end %}
|
||||
{% end %}
|
||||
|
|
Loading…
Reference in a new issue