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

Using type in where block raise ArgumentError #433

Open
thomasbaustert opened this issue Nov 15, 2024 · 0 comments
Open

Using type in where block raise ArgumentError #433

thomasbaustert opened this issue Nov 15, 2024 · 0 comments

Comments

@thomasbaustert
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant