I've noticed that rom-repository doesn't handle whitespaces in attribute names while working with a mssql database.
Here is my schema:
CREATE TABLE dbo.bugs
( id int NOT NULL
, white space nvarchar(max) NULL
)
the script:
require 'rom-sql'
require 'rom-repository'
container = ROM.container(:sql, "tinytds://foo:bar@localhost/bug") do |config|
config.relation(:bugs)
end
class BugsRepository < ROM::Repository[:bugs]
end
container.relations[:bugs].delete
container.relations[:bugs].insert("id" => 1, "white space" => "WTF")
BugsRepository.new(container).bugs.to_a
and the stacktrace:
/Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/open_struct.rb:13:in `instance_variable_set': `@white space' is not allowed as an instance variable name (NameError)
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/open_struct.rb:13:in `block in initialize'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/open_struct.rb:12:in `each'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/open_struct.rb:12:in `initialize'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/class.rb:30:in `new'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/class.rb:30:in `constructor_inject'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/function.rb:47:in `call'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/function.rb:47:in `call'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/array.rb:42:in `block in map_array'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/array.rb:42:in `map'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/array.rb:42:in `map_array'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/function.rb:47:in `call'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/transproc-1.0.2/lib/transproc/function.rb:47:in `call'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/mapper.rb:95:in `block in call'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/mapper.rb:95:in `each'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/mapper.rb:95:in `reduce'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-mapper-1.0.0.beta1/lib/rom/mapper.rb:95:in `call'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-core-4.0.0.beta1/lib/rom/relation.rb:169:in `each'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-core-4.0.0.beta1/lib/rom/relation.rb:268:in `each'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-core-4.0.0.beta1/lib/rom/relation.rb:268:in `to_a'
from /Users/wrozka/.rvm/gems/ruby-2.4.1/gems/rom-core-4.0.0.beta1/lib/rom/relation.rb:268:in `to_a'
from bug.rb:14:in `<main>'
I'd say we should raise an error if an attribute has whitespaces and no sensible alias was provided. We can't use attribute names with whitespaces because Ruby doesn't allow setting ivars with names containing ws :)
I've noticed that
rom-repository
doesn't handle whitespaces in attribute names while working with a mssql database.Here is my schema:
the script:
and the stacktrace:
It fails in both
0.5.1
and1.0.0.beta1