Skip to content

Using type in where block raise ArgumentError #433

@thomasbaustert

Description

@thomasbaustert

Describe the bug

Using where { type.is(...) } raises ArgumentError: wrong number of arguments (given 0, expected 1).

To Reproduce

Run script below:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  require 'rom-sql'
  require 'sqlite3'
end

config = ROM::Configuration.new(:sql, 'sqlite::memory')

config.gateways[:default].create_table(:users) do
  primary_key :id
  column :name, String
  column :type, String
end

class Users < ROM::Relation[:sql]
  schema do
    attribute :id, Types::Serial
    attribute :name, Types::String
    attribute :type, Types::Strict::String.enum('User', 'Admin')
  end
end

config.register_relation(Users)

container = ROM.container(config)

users = container.relations[:users]

# ArgumentError: wrong number of arguments (given 0, expected 1)
p users.where { name.is('Thomas') & type.is('Manager') }.to_a

Expected behavior

It does not raise an error but considers type as a database column.

My environment

  • Ruby: 3.2.2
  • rom-sql (3.6.4)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions