Validates uniqueness of FAILURE Help!

Hi all,

Running Rails: 2.3.5
Ruby: 1.8.7p302
Firebird: 2.1

I am running into a weird issue. When connecting to a firebird database
I get the following on any model that uses “validates_uniqueness_of”.
Other validations work fine. The unique check is simply on a name field.
I should add this code works fine with Postgres…no issues. Access to
all tables for reads / writes without the unique validation works
without issue on the Firebird database.

These models worked without issue on earlier versions of ruby 1.8.6 and
rails 2.1.1 AND firebird.

Can anyone point me in a direction to better understand what is going on
here?

Does the Firbird DB need to be Multibyte as well? Is there anyway to
prevent using multibyte?

ActiveRecord::StatementInvalid in RoleController#create

RangeError: VARCHAR overflow: 72 bytes exceeds 64 byte(s) allowed.:
SELECT FIRST 1 “OC_USER_ROLE”.id FROM “OC_USER_ROLE” WHERE
(“OC_USER_ROLE”.“NAME” = ?) , —
!ruby/object:ActiveSupport::Multibyte::Chars
wrapped_string: Testname

RAILS_ROOT: D:/4.3Branch/webui
Application Trace | Framework Trace | Full Trace

D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:219:in
log' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/connection_adapters/fb_adapter.rb:306:inlog’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/connection_adapters/fb_adapter.rb:311:in
select_all' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/connection_adapters/fb_adapter.rb:294:intranslate’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/connection_adapters/fb_adapter.rb:310:in
select_all' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/base.rb:665:infind_by_sql’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/base.rb:1556:in
find_every' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/base.rb:1513:infind_initial’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/base.rb:700:in
exists?' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:827:invalidates_uniqueness_of’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/base.rb:2151:in
with_scope' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/base.rb:2159:inwith_exclusive_scope’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:826:in
validates_uniqueness_of' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:468:invalidates_each’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:465:in
each' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:465:invalidates_each’
D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in
call' D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:inevaluate_method’
D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in
call' D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:inrun’
D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in
each' D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:insend’
D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in
run' D:/4.3Branch/webui/vendor/rails/activesupport/lib/active_support/callbacks.rb:276:inrun_callbacks’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:1098:in
valid_without_callbacks?' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/callbacks.rb:315:invalid?’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/validations.rb:1077:in
save_without_dirty' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/dirty.rb:79:insave_without_transactions’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:229:in
send' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:229:inwith_transaction_returning_status’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in
transaction' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:182:intransaction’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:228:in
with_transaction_returning_status' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:196:insave’
D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:208:in
rollback_active_record_state!' D:/4.3Branch/webui/vendor/rails/activerecord/lib/active_record/transactions.rb:196:insave’
D:/4.3Branch/webui/app/controllers/role_controller.rb:278:in `create’

On Apr 1, 4:46pm, “Rick F.” [email protected] wrote:

all tables for reads / writes without the unique validation works

ActiveSupport adds somestuff to strings to allow utf8 strings to be
operated on safely (eg truncation etc) and to provide various unicodey
utilities. various operations (like some_string.mb_chars.reverse) will
return a MultiByte::Chars object, but this is supposed to be done in a
way that it still looks like the string the chars object is wrapping.

In your particular case this isn’t happening - while building that
string instead of just using the wrapper string (Testname) it’s
serializing the whole MB::Chars object which is wrong. Don’t know why
it’s happening though

Fred

Thanks Fred,

So I backed the rails version to 2.3.3 and all is well again. I would
think others would see this issue as well in 2.3.5?? I tried 2.3.11 and
the problem for me remains there as well.

Anyway, I am going to see if I can find out what changed between 2.3.3
and 2.3.5 to cause my pain.

Thanks again.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs