Using `type` in `where` block raise `ArgumentError`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start by running the inline Ruby reproduction and tracing the users.where block, especially attribute lookup for the column named type. Done means the block treats type as the database column and no longer raises ArgumentError; rerun the supplied script to verify the result.
Written by the indexing model from the issue text.
Description
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)
- Dominant language
- Ruby
- Stars
- 220
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rom-rb/rom-sql
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
バグ
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
voxpupuli/puppet-epel#186 · 1 comment ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) OpenBug Frontend
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TheOdinProject/curriculum#31402 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100