Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while requiring "clear" #133

Closed
RemiKalbe opened this issue Jul 21, 2019 · 6 comments
Closed

Error while requiring "clear" #133

RemiKalbe opened this issue Jul 21, 2019 · 6 comments

Comments

@RemiKalbe
Copy link

RemiKalbe commented Jul 21, 2019

No idea what is happening I literally didn't do anything except installing another shard and now everything is broken.
(Deleting the new shard I installed didn't solve the issue)
Even using an old version of my code that was working now don't work.

Error in src/dwoom-account-backend-user.cr:9: while requiring "clear"

require "clear"
^

in lib/clear/src/clear.cr:19: while requiring "./clear/core"

require "./clear/core"
^

in lib/clear/src/clear/core.cr:16: while requiring "./model/**"

require "./model/**"
^

in lib/clear/src/clear/model/model.cr:84: while requiring "./reflection/**"

require "./reflection/**"
^

in lib/clear/src/clear/model/reflection/column.cr:4: expanding macro

  include Clear::Model
  ^

in macro 'included' expanded macro: included:1, line 22:

   1.       @@initialized = false
   2.
   3.       # :nodoc:
   4.       macro __on_init__
   5.         class ::{{@type}}
   6.           def self.__main_init__
   7.             previous_def
   8.             {{yield}}
   9.           end
  10.
  11.         end
  12.       end
  13.
  14.       # :nodoc:
  15.       def self.__initialize_once__
  16.         unless @@initialized
  17.           __main_init__
  18.           @@initialized = true
  19.         end
  20.       end
  21.
> 22.       __initialize_once__
  23.

instantiating '__initialize_once__()'
in lib/clear/src/clear/model/reflection/column.cr:4: expanding macro

  include Clear::Model
  ^

in macro 'included' expanded macro: included:1, line 17:

   1.       @@initialized = false
   2.
   3.       # :nodoc:
   4.       macro __on_init__
   5.         class ::{{@type}}
   6.           def self.__main_init__
   7.             previous_def
   8.             {{yield}}
   9.           end
  10.
  11.         end
  12.       end
  13.
  14.       # :nodoc:
  15.       def self.__initialize_once__
  16.         unless @@initialized
> 17.           __main_init__
  18.           @@initialized = true
  19.         end
  20.       end
  21.
  22.       __initialize_once__
  23.

instantiating '__main_init__()'
in macro 'generate' /Users/remivillien/Git/Dwoom/dwoom-account-backend-user/lib/clear/src/clear/model/modules/relations/belongs_to_macro.cr:3, line 62:

   1.
   2.
   3.
   4.
   5.     column table_name : ::Union(String, ::Nil), primary: false, presence: true
   6.     getter _cached_table : Clear::Reflection::Table?
   7.
   8.     # The method table is a `belongs_to` relation
   9.     #   to Clear::Reflection::Table
  10.     def table : Clear::Reflection::Table | Nil
  11.       if cached = @cached_table
  12.         cached
  13.       else
  14.         cache = @cache
  15.
  16.         if cache && cache.active? "table"
  17.
  18.             @cached_table = cache.hit("table",
  19.               self.table_name_column.to_sql_value, Clear::Reflection::Table
  20.             ).first?
  21.
  22.
  23.         else
  24.
  25.           @cached_table = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey) == self.table_name }.first
  26.
  27.         end
  28.       end
  29.     end # / *
  30.
  31.
  32.     def table! : Clear::Reflection::Table
  33.       table.not_nil!
  34.     end # /  *!
  35.
  36.
  37.     def table=(x : Clear::Reflection::Table | Nil)
  38.       if x && x.persisted?
  39.         raise "#{x.pkey_column.name} must be defined when assigning a belongs_to relation." unless x.pkey_column.defined?
  40.         @table_name_column.value = x.pkey
  41.       end
  42.
  43.       @cached_table = x
  44.     end
  45.
  46.
  47.     # :nodoc:
  48.     # save the belongs_to model first if needed
  49.     def _bt_save_table
  50.       c = @cached_table
  51.       return if c.nil?
  52.
  53.       unless c.persisted?
  54.         if c.save
  55.           @table_name_column.value = c.pkey
  56.         else
  57.           add_error("table", c.print_errors)
  58.         end
  59.       end
  60.     end # / _bt_save_*
  61.
> 62.     __on_init__ do
  63.       Clear::Reflection::Column.before(:validate) do |mdl|
  64.         mdl.as(self)._bt_save_table
  65.       end
  66.     end
  67.
  68.     class Collection
  69.       def with_table(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self
  70.         before_query do
  71.           sub_query = self.dup.clear_select.select("#{Clear::Reflection::Column.table}.table_name")
  72.
  73.           cached_qry = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey).in?(sub_query) }
  74.
  75.           block.call(cached_qry)
  76.
  77.           @cache.active "table"
  78.
  79.           cached_qry.each(fetch_columns: fetch_columns) do |mdl|
  80.             @cache.set("table", mdl.pkey, [mdl])
  81.           end
  82.         end
  83.
  84.         self
  85.       end # / with_*
  86.
  87.       def with_table(fetch_columns = false) : self
  88.         with_table(fetch_columns){}
  89.         self
  90.       end # / with_*
  91.
  92.     end # / Collection
  93.
  94.

expanding macro
in macro '__on_init__' expanded macro: included:4, line 5:

   1.         class ::Clear::Reflection::Column
   2.           def self.__main_init__
   3.             previous_def
   4.             begin Clear::Reflection::Column.before(:validate) do |mdl|
>  5.   (mdl.as(self))._bt_save_table
   6. end end
   7.           end
   8.
   9.         end
  10.

instantiating 'Clear::Reflection::Column#_bt_save_table()'
in macro '__generate_relations__' /Users/remivillien/Git/Dwoom/dwoom-account-backend-user/lib/clear/src/clear/model/modules/has_relations.cr:160, line 4:

   1.
   2.
   3.
>  4.         Relations::BelongsToMacro.generate(Clear::Reflection::Column, table, Clear::Reflection::Table, true, table_name,
   5.           false, false, String?)
   6.
   7.
   8.
   9.

expanding macro
in macro 'generate' /Users/remivillien/Git/Dwoom/dwoom-account-backend-user/lib/clear/src/clear/model/modules/relations/belongs_to_macro.cr:3, line 54:

   1.
   2.
   3.
   4.
   5.     column table_name : ::Union(String, ::Nil), primary: false, presence: true
   6.     getter _cached_table : Clear::Reflection::Table?
   7.
   8.     # The method table is a `belongs_to` relation
   9.     #   to Clear::Reflection::Table
  10.     def table : Clear::Reflection::Table | Nil
  11.       if cached = @cached_table
  12.         cached
  13.       else
  14.         cache = @cache
  15.
  16.         if cache && cache.active? "table"
  17.
  18.             @cached_table = cache.hit("table",
  19.               self.table_name_column.to_sql_value, Clear::Reflection::Table
  20.             ).first?
  21.
  22.
  23.         else
  24.
  25.           @cached_table = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey) == self.table_name }.first
  26.
  27.         end
  28.       end
  29.     end # / *
  30.
  31.
  32.     def table! : Clear::Reflection::Table
  33.       table.not_nil!
  34.     end # /  *!
  35.
  36.
  37.     def table=(x : Clear::Reflection::Table | Nil)
  38.       if x && x.persisted?
  39.         raise "#{x.pkey_column.name} must be defined when assigning a belongs_to relation." unless x.pkey_column.defined?
  40.         @table_name_column.value = x.pkey
  41.       end
  42.
  43.       @cached_table = x
  44.     end
  45.
  46.
  47.     # :nodoc:
  48.     # save the belongs_to model first if needed
  49.     def _bt_save_table
  50.       c = @cached_table
  51.       return if c.nil?
  52.
  53.       unless c.persisted?
> 54.         if c.save
  55.           @table_name_column.value = c.pkey
  56.         else
  57.           add_error("table", c.print_errors)
  58.         end
  59.       end
  60.     end # / _bt_save_*
  61.
  62.     __on_init__ do
  63.       Clear::Reflection::Column.before(:validate) do |mdl|
  64.         mdl.as(self)._bt_save_table
  65.       end
  66.     end
  67.
  68.     class Collection
  69.       def with_table(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self
  70.         before_query do
  71.           sub_query = self.dup.clear_select.select("#{Clear::Reflection::Column.table}.table_name")
  72.
  73.           cached_qry = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey).in?(sub_query) }
  74.
  75.           block.call(cached_qry)
  76.
  77.           @cache.active "table"
  78.
  79.           cached_qry.each(fetch_columns: fetch_columns) do |mdl|
  80.             @cache.set("table", mdl.pkey, [mdl])
  81.           end
  82.         end
  83.
  84.         self
  85.       end # / with_*
  86.
  87.       def with_table(fetch_columns = false) : self
  88.         with_table(fetch_columns){}
  89.         self
  90.       end # / with_*
  91.
  92.     end # / Collection
  93.
  94.

instantiating 'Clear::Reflection::Table#save()'
in lib/clear/src/clear/model/modules/has_saving.cr:97: instantiating 'with_triggers(Symbol)'

    with_triggers(:save) do
    ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:97: instantiating 'with_triggers(Symbol)'

    with_triggers(:save) do
    ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:109: instantiating 'with_triggers(Symbol)'

          with_triggers(:create) do
          ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:109: instantiating 'with_triggers(Symbol)'

          with_triggers(:create) do
          ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:112: instantiating 'Clear::SQL::InsertQuery#execute(String)'

            hash = query.execute(@@connection)
                         ^~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:82: instantiating 'fetch(String)'

      fetch(connection_name) { |x| o = x }
      ^~~~~

in lib/clear/src/clear/sql/insert_query.cr:44: instantiating 'Clear::SQL:Module#log_query(String)'

    Clear::SQL.log_query to_sql do
               ^~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:44: instantiating 'Clear::SQL:Module#log_query(String)'

    Clear::SQL.log_query to_sql do
               ^~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:47: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:47: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:48: instantiating 'DB::Database#query(String)'

        cnx.query(to_sql) do |rs|
            ^~~~~

in lib/clear/src/clear/sql/insert_query.cr:48: instantiating 'DB::Database#query(String)'

        cnx.query(to_sql) do |rs|
            ^~~~~

in lib/clear/src/clear/sql/insert_query.cr:49: instantiating 'fetch_result_set(Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil), PG::ResultSet)'

          fetch_result_set(h, rs) { |x| yield(x) }
          ^~~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:59: instantiating 'loop()'

    loop do
    ^~~~

in lib/clear/src/clear/sql/insert_query.cr:59: instantiating 'loop()'

    loop do
    ^~~~

in lib/clear/src/clear/sql/insert_query.cr:60: instantiating 'PG::ResultSet#each_column()'

      rs.each_column do |col|
         ^~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:60: instantiating 'PG::ResultSet#each_column()'

      rs.each_column do |col|
         ^~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:61: no overload matches 'Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)#[]=' with types String, (Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil)
Overloads are:
 - Hash(K, V)#[]=(key : K, value : V)
Couldn't find overloads for these types:
 - Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)#[]=(key : String, value : Array(PG::NumericArray))
 - Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)#[]=(key : String, value : Array(PG::TimeArray))

        h[col] = rs.read
         ^


dwoom-account-backend-user on  master [!] on 🐳 v18.09.2 at ☸️  do-ams3-dwoom-dev-ams3-1
➜ crystal run ./src/dwoom-account-backend-user.cr
Error in src/dwoom-account-backend-user.cr:9: while requiring "clear"

require "clear"
^

in lib/clear/src/clear.cr:19: while requiring "./clear/core"

require "./clear/core"
^

in lib/clear/src/clear/core.cr:16: while requiring "./model/**"

require "./model/**"
^

in lib/clear/src/clear/model/model.cr:84: while requiring "./reflection/**"

require "./reflection/**"
^

in lib/clear/src/clear/model/reflection/column.cr:4: expanding macro

  include Clear::Model
  ^

in macro 'included' expanded macro: included:1, line 22:

   1.       @@initialized = false
   2.
   3.       # :nodoc:
   4.       macro __on_init__
   5.         class ::{{@type}}
   6.           def self.__main_init__
   7.             previous_def
   8.             {{yield}}
   9.           end
  10.
  11.         end
  12.       end
  13.
  14.       # :nodoc:
  15.       def self.__initialize_once__
  16.         unless @@initialized
  17.           __main_init__
  18.           @@initialized = true
  19.         end
  20.       end
  21.
> 22.       __initialize_once__
  23.

instantiating '__initialize_once__()'
in lib/clear/src/clear/model/reflection/column.cr:4: expanding macro

  include Clear::Model
  ^

in macro 'included' expanded macro: included:1, line 17:

   1.       @@initialized = false
   2.
   3.       # :nodoc:
   4.       macro __on_init__
   5.         class ::{{@type}}
   6.           def self.__main_init__
   7.             previous_def
   8.             {{yield}}
   9.           end
  10.
  11.         end
  12.       end
  13.
  14.       # :nodoc:
  15.       def self.__initialize_once__
  16.         unless @@initialized
> 17.           __main_init__
  18.           @@initialized = true
  19.         end
  20.       end
  21.
  22.       __initialize_once__
  23.

instantiating '__main_init__()'
in macro 'generate' /Users/remivillien/Git/Dwoom/dwoom-account-backend-user/lib/clear/src/clear/model/modules/relations/belongs_to_macro.cr:3, line 62:

   1.
   2.
   3.
   4.
   5.     column table_name : ::Union(String, ::Nil), primary: false, presence: true
   6.     getter _cached_table : Clear::Reflection::Table?
   7.
   8.     # The method table is a `belongs_to` relation
   9.     #   to Clear::Reflection::Table
  10.     def table : Clear::Reflection::Table | Nil
  11.       if cached = @cached_table
  12.         cached
  13.       else
  14.         cache = @cache
  15.
  16.         if cache && cache.active? "table"
  17.
  18.             @cached_table = cache.hit("table",
  19.               self.table_name_column.to_sql_value, Clear::Reflection::Table
  20.             ).first?
  21.
  22.
  23.         else
  24.
  25.           @cached_table = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey) == self.table_name }.first
  26.
  27.         end
  28.       end
  29.     end # / *
  30.
  31.
  32.     def table! : Clear::Reflection::Table
  33.       table.not_nil!
  34.     end # /  *!
  35.
  36.
  37.     def table=(x : Clear::Reflection::Table | Nil)
  38.       if x && x.persisted?
  39.         raise "#{x.pkey_column.name} must be defined when assigning a belongs_to relation." unless x.pkey_column.defined?
  40.         @table_name_column.value = x.pkey
  41.       end
  42.
  43.       @cached_table = x
  44.     end
  45.
  46.
  47.     # :nodoc:
  48.     # save the belongs_to model first if needed
  49.     def _bt_save_table
  50.       c = @cached_table
  51.       return if c.nil?
  52.
  53.       unless c.persisted?
  54.         if c.save
  55.           @table_name_column.value = c.pkey
  56.         else
  57.           add_error("table", c.print_errors)
  58.         end
  59.       end
  60.     end # / _bt_save_*
  61.
> 62.     __on_init__ do
  63.       Clear::Reflection::Column.before(:validate) do |mdl|
  64.         mdl.as(self)._bt_save_table
  65.       end
  66.     end
  67.
  68.     class Collection
  69.       def with_table(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self
  70.         before_query do
  71.           sub_query = self.dup.clear_select.select("#{Clear::Reflection::Column.table}.table_name")
  72.
  73.           cached_qry = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey).in?(sub_query) }
  74.
  75.           block.call(cached_qry)
  76.
  77.           @cache.active "table"
  78.
  79.           cached_qry.each(fetch_columns: fetch_columns) do |mdl|
  80.             @cache.set("table", mdl.pkey, [mdl])
  81.           end
  82.         end
  83.
  84.         self
  85.       end # / with_*
  86.
  87.       def with_table(fetch_columns = false) : self
  88.         with_table(fetch_columns){}
  89.         self
  90.       end # / with_*
  91.
  92.     end # / Collection
  93.
  94.

expanding macro
in macro '__on_init__' expanded macro: included:4, line 5:

   1.         class ::Clear::Reflection::Column
   2.           def self.__main_init__
   3.             previous_def
   4.             begin Clear::Reflection::Column.before(:validate) do |mdl|
>  5.   (mdl.as(self))._bt_save_table
   6. end end
   7.           end
   8.
   9.         end
  10.

instantiating 'Clear::Reflection::Column#_bt_save_table()'
in macro '__generate_relations__' /Users/remivillien/Git/Dwoom/dwoom-account-backend-user/lib/clear/src/clear/model/modules/has_relations.cr:160, line 4:

   1.
   2.
   3.
>  4.         Relations::BelongsToMacro.generate(Clear::Reflection::Column, table, Clear::Reflection::Table, true, table_name,
   5.           false, false, String?)
   6.
   7.
   8.
   9.

expanding macro
in macro 'generate' /Users/remivillien/Git/Dwoom/dwoom-account-backend-user/lib/clear/src/clear/model/modules/relations/belongs_to_macro.cr:3, line 54:

   1.
   2.
   3.
   4.
   5.     column table_name : ::Union(String, ::Nil), primary: false, presence: true
   6.     getter _cached_table : Clear::Reflection::Table?
   7.
   8.     # The method table is a `belongs_to` relation
   9.     #   to Clear::Reflection::Table
  10.     def table : Clear::Reflection::Table | Nil
  11.       if cached = @cached_table
  12.         cached
  13.       else
  14.         cache = @cache
  15.
  16.         if cache && cache.active? "table"
  17.
  18.             @cached_table = cache.hit("table",
  19.               self.table_name_column.to_sql_value, Clear::Reflection::Table
  20.             ).first?
  21.
  22.
  23.         else
  24.
  25.           @cached_table = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey) == self.table_name }.first
  26.
  27.         end
  28.       end
  29.     end # / *
  30.
  31.
  32.     def table! : Clear::Reflection::Table
  33.       table.not_nil!
  34.     end # /  *!
  35.
  36.
  37.     def table=(x : Clear::Reflection::Table | Nil)
  38.       if x && x.persisted?
  39.         raise "#{x.pkey_column.name} must be defined when assigning a belongs_to relation." unless x.pkey_column.defined?
  40.         @table_name_column.value = x.pkey
  41.       end
  42.
  43.       @cached_table = x
  44.     end
  45.
  46.
  47.     # :nodoc:
  48.     # save the belongs_to model first if needed
  49.     def _bt_save_table
  50.       c = @cached_table
  51.       return if c.nil?
  52.
  53.       unless c.persisted?
> 54.         if c.save
  55.           @table_name_column.value = c.pkey
  56.         else
  57.           add_error("table", c.print_errors)
  58.         end
  59.       end
  60.     end # / _bt_save_*
  61.
  62.     __on_init__ do
  63.       Clear::Reflection::Column.before(:validate) do |mdl|
  64.         mdl.as(self)._bt_save_table
  65.       end
  66.     end
  67.
  68.     class Collection
  69.       def with_table(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self
  70.         before_query do
  71.           sub_query = self.dup.clear_select.select("#{Clear::Reflection::Column.table}.table_name")
  72.
  73.           cached_qry = Clear::Reflection::Table.query.where{ raw(Clear::Reflection::Table.pkey).in?(sub_query) }
  74.
  75.           block.call(cached_qry)
  76.
  77.           @cache.active "table"
  78.
  79.           cached_qry.each(fetch_columns: fetch_columns) do |mdl|
  80.             @cache.set("table", mdl.pkey, [mdl])
  81.           end
  82.         end
  83.
  84.         self
  85.       end # / with_*
  86.
  87.       def with_table(fetch_columns = false) : self
  88.         with_table(fetch_columns){}
  89.         self
  90.       end # / with_*
  91.
  92.     end # / Collection
  93.
  94.

instantiating 'Clear::Reflection::Table#save()'
in lib/clear/src/clear/model/modules/has_saving.cr:97: instantiating 'with_triggers(Symbol)'

    with_triggers(:save) do
    ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:97: instantiating 'with_triggers(Symbol)'

    with_triggers(:save) do
    ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:109: instantiating 'with_triggers(Symbol)'

          with_triggers(:create) do
          ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/sql.cr:118: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_hooks.cr:16: instantiating 'Clear::SQL:Module#transaction()'

    Clear::SQL.transaction do
               ^~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:109: instantiating 'with_triggers(Symbol)'

          with_triggers(:create) do
          ^~~~~~~~~~~~~

in lib/clear/src/clear/model/modules/has_saving.cr:112: instantiating 'Clear::SQL::InsertQuery#execute(String)'

            hash = query.execute(@@connection)
                         ^~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:82: instantiating 'fetch(String)'

      fetch(connection_name) { |x| o = x }
      ^~~~~

in lib/clear/src/clear/sql/insert_query.cr:44: instantiating 'Clear::SQL:Module#log_query(String)'

    Clear::SQL.log_query to_sql do
               ^~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:44: instantiating 'Clear::SQL:Module#log_query(String)'

    Clear::SQL.log_query to_sql do
               ^~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:47: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:47: instantiating 'Clear::SQL::ConnectionPool.class#with_connection(String)'

      Clear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|
                                 ^~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:48: instantiating 'DB::Database#query(String)'

        cnx.query(to_sql) do |rs|
            ^~~~~

in lib/clear/src/clear/sql/insert_query.cr:48: instantiating 'DB::Database#query(String)'

        cnx.query(to_sql) do |rs|
            ^~~~~

in lib/clear/src/clear/sql/insert_query.cr:49: instantiating 'fetch_result_set(Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil), PG::ResultSet)'

          fetch_result_set(h, rs) { |x| yield(x) }
          ^~~~~~~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:59: instantiating 'loop()'

    loop do
    ^~~~

in lib/clear/src/clear/sql/insert_query.cr:59: instantiating 'loop()'

    loop do
    ^~~~

in lib/clear/src/clear/sql/insert_query.cr:60: instantiating 'PG::ResultSet#each_column()'

      rs.each_column do |col|
         ^~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:60: instantiating 'PG::ResultSet#each_column()'

      rs.each_column do |col|
         ^~~~~~~~~~~

in lib/clear/src/clear/sql/insert_query.cr:61: no overload matches 'Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)#[]=' with types String, (Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | Nil)
Overloads are:
 - Hash(K, V)#[]=(key : K, value : V)
Couldn't find overloads for these types:
 - Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)#[]=(key : String, value : Array(PG::NumericArray))
 - Hash(String, Array(JSON::Any) | Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::StringArray) | Bool | Char | Clear::Expression::UnsafeSql | Float32 | Float64 | Hash(String, JSON::Any) | Int16 | Int32 | Int64 | Int8 | JSON::Any | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)#[]=(key : String, value : Array(PG::TimeArray))

        h[col] = rs.read
@RemiKalbe
Copy link
Author

I opened another of my project that uses clear to see if this is related somehow to my project.
It works fine, then I did shards install without having anything to install and now I got the same issue.

@anykeyh
Copy link
Owner

anykeyh commented Jul 21, 2019

That's a long stacktrace 😄

Can you give me info about your crystal and clear version? crystal -v and the clear info in shards.lock ?

@remydev
Copy link
Contributor

remydev commented Jul 21, 2019

did you see #131 ?

@RemiKalbe
Copy link
Author

Crystal 0.29.0 (2019-06-06)

LLVM: 6.0.1
Default target: x86_64-apple-macosx

So I took a look at what changed in my shards.lock, and apparently it's this:

pg:
    github: will/crystal-pg
    version: 0.16.1

to

pg:
    github: will/crystal-pg
    version: 0.17

Here is my complete shards.lock file

version: 1.0
shards:
  admiral:
    github: jwaldrip/admiral.cr
    commit: 0892415a8775fe59ff4c6de6cb5b21da8c9acd8e

  ameba:
    github: veelenga/ameba
    version: 0.10.0

  base62:
    github: Sija/base62.cr
    version: 0.1.1

  clear:
    github: anykeyh/clear
    commit: ec2714b33f0f84d8a1bcc23e90a53868260ca1a3

  crest:
    github: mamantoha/crest
    version: 0.20.0

  crystal-argon2:
    github: sushichain/crystal-argon2
    version: 0.1.0

  db:
    github: crystal-lang/crystal-db
    version: 0.5.1

  dotenv:
    github: gdotdesign/cr-dotenv
    version: 0.2.0

  exception_page:
    github: crystal-loot/exception_page
    version: 0.1.2

  generate:
    github: anykeyh/generate.cr
    commit: 27a59d663ded8ce39a361e3a88b8dd747f59ce42

  inflector:
    github: phoffer/inflector.cr
    version: 0.1.8

  kemal:
    github: kemalcr/kemal
    version: 0.25.2

  kilt:
    github: jeromegn/kilt
    version: 0.4.0

  ksuid:
    github: Sija/ksuid.cr
    version: 0.4.0

  pg:
    github: will/crystal-pg
    version: 0.17.0

  radix:
    github: luislavena/radix
    version: 0.3.9

  spec-kemal:
    github: kemalcr/spec-kemal
    commit: 64b89c719234ceb92c0a14762dce3afc6257fffc

@anykeyh
Copy link
Owner

anykeyh commented Jul 21, 2019

Indeed, the problem comes from crystal pg v0.17. I'll see what's happening. Meanwhile you can force in your shards.yml the version 0.16.1

@anykeyh
Copy link
Owner

anykeyh commented Jul 21, 2019

I've fixed the code, please use branch: master for having Clear working with pg v0.17

@anykeyh anykeyh closed this as completed Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants