Comments (18)
Yeah I'm definitely shooting for a drop-in replacement, or as close to it as I can get ;)
No worries on reporting these issues, keep 'em comin!
I'll try and take a look at this one soon
from mysql2.
Ok try it now (http://github.com/brianmario/mysql2/commit/e01c7581e5a34fc25920b487d8a2ad102dd8b2d1)
from mysql2.
That commit causes any test in my app that tries to save an AR object to fail :)
All models that have a related object (Invoice belongs_to Company, a valid invoice instance fails to save because it thinks Invoice#company is nil).
from mysql2.
Any other info about why they aren't saving?
from mysql2.
Btw, I'm running my adapter against the rails test suite for the existing mysql gem and adapter to try and get those all passing
from mysql2.
OK, that was a really lame comment with no details. My aplogies :)
I have a company model that has the following validation:
class Company < ActiveRecord::Base
..
validates_numericality_of :standard_float, :greater_than => 0, :allow_nil => true
..
end
The company model is created in nearly every test, so a failure in saving it triggers a sea of red across my test suite.
>> c = Company.new
=> #<Company id: nil, standard_float: nil>
>> c.save!
ActiveRecord::RecordInvalid: Validation failed: Standard float must be greater than 0
So it's calling c.standard_float invalid, even though my validation rule says nil is ok.
from mysql2.
Ok, hopefully this is the last iteration on this casting madness :P
http://github.com/brianmario/mysql2/commit/6b285dcd85698e427d0498c6855f831572b6747a
from mysql2.
Whoops, pushed a typo in that commit, it's been fixed so try with the latest
from mysql2.
Down from 11 failures to 7! Running late for a dinner thing, so will send you detailed into later tonight.
from mysql2.
(and the failures look like a different issue)
from mysql2.
>> Supplier.last.update_attributes!(:payment_days => [])
NameError: undefined local variable or method value' for #<Supplier:0x7ff10c474a50> from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in
method_missing'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:211:in payment_days' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:466:in
send'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:466
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:465:in each' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:465 from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in
call'
from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:182:in evaluate_method' from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in
call'
from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in run' from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in
each'
from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in send' from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:90:in
run'
from /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in run_callbacks' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1098:in
valid_without_callbacks?'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:315:in valid?' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/validations.rb:1087:in
save_without_dirty!'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/dirty.rb:87:in save_without_transactions!' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in
save!'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in transaction' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in
transaction'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in save!' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:208:in
rollback_active_record_state!'
from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:200:in save!' from /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2635:in
update_attributes!'
from (irb):4>>
from mysql2.
I should add that Supplier.payment_days is an int attribute defined like so:
`payment_days` int(11) NOT NULL DEFAULT '30',
with the following validation on it:
validates_numericality_of :payment_days, :greater_than_or_equal_to => 0
from mysql2.
Damn, had another typo... pushed - try one last time? (sorry if this is getting annoying :P)
from mysql2.
I thought my tests covered these cases, but apparently not... Will add more soon
from mysql2.
With 86b9ffe I drop from 7 failures to 4, but with 48db89 it jumps back up to 154.
The 4 failures are on methods where I'm doing a direct call to SomeModel.connection.select_all(....). All values returned are strings, so I'm manually casting the decimals to BigDecimals. That fails with mysql2, as they're already decimals. Arguably I'd say you could leave that as is, people shouldn't be dropping down to raw SQL too often.
Most of the 154 failures seems to be "String can't be coerced into Fixnum" and are triggered by aggregate functions on associations returning a string instead of a number:
>> CustomerOrderItem.last.approval_items.sum(:quantity)
=> "0"
from mysql2.
Was afraid of that, I reverted 48db89. Really sucks that I have to leave this casting stuff in because AR makes incorrect assumptions about the data all over in places I don't have control over :(
Anyway, if things after this revert go back to "normal" and have only the 4 failing tests; I may push 0.1.6 - as for those tests, could just check if it's already a BigDecimal before attempting to cast and have them all pass?
from mysql2.
OK, b676a3 takes me back to 4 failures.
I've adapted my model code that is calling select_all() to prevent it passing a BigDecimal back into the BigDecimal constructor, so now my full suite is running green.
Thanks!
from mysql2.
awesome, thank you soooo much for all the testing!
from mysql2.
Related Issues (20)
- cast: false doesn't work for prepared statements
- Mysql2::Error: Unsupported charset: '"utf8mb3"'
- ld: library not found for -lzlib HOT 7
- Disregard
- Segmentation faults randomly when running test on CircleCI (Rails, Minitest)
- mysql2 v0.5.5 with brew ruby v3.2.2_1 lead dyld[13277]: missing symbol called trap HOT 3
- Ruby 2.3.4 & mysql2-0.5.3 [BUG] Segmentation fault HOT 1
- Mysql2::Client session_track specs fail against MySQL 8.0.33 HOT 1
- MySQL 8.0.34 and 8.1.0 deprecates `MYSQL_OPT_RECONNECT` HOT 10
- Unable to install 0.5.5 on Macbook M2 HOT 3
- All gem DL locations wrong? Or am I doing something terribly wrong? HOT 2
- Does a mysql2 to MySQL version compatibility list exist? HOT 3
- LoadError: libruby.so.2.7: cannot open shared object file: No such file or directory HOT 1
- Samplog_Init HOT 1
- MySQL 8.1 and mysql2 gem version 0.5.5 - ArgumentError: negative string size (or size too big) HOT 6
- Error installing mysql2 on Mac M1 pro (ventura) HOT 4
- "pluggable authentication is not available" for recent client library HOT 1
- UUID support? HOT 2
- "Commands out of sync" exceptions with threads and prepared statements. HOT 2
- Error installing v0.5.5 on Rails app with ruby 3.3.0 on macOS Sonoma v14.2 M2 chipset HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mysql2.