Thanks, good to know :) So is the answer to the bigger question: "How can I not ERROR on MySQL WARNINGS?" pretty much "Migrate your entire legacy database!".
This seems like something that should be added to DataObjects as a config option. Obviously, somewhere in DataObjects it's doing (pseudo-code): result_set = connection.execute( .... ) raise SQLError "Some stuff" if (connection.warning_count > 0) # Even though warning != error It looks like it's actually just a thin wrapper around JDBC, so maybe this is the default JDBC behaviour? This must affect a lot of people who have to continue to work with large legacy databases, I assume. I briefly poked around in the source to see if I could modify this behaviour myself, but failed to find where it actually raises the error. If a developer who know the internals could at least point me in the right direction I don't mind getting my hands dirty and contributing something back. El 05/05/2011, a las 08:54, RipTheJacker escribió: > for logging: http://pastie.org/1843979 > > On May 4, 11:35 am, Chris Corbyn <[email protected]> wrote: >> Hi, >> >> I'm new to DataMapper but have found myself using it as I port a PHP >> application to Rails, which has a completely un-rails-like schema. >> >> My understanding is that DataMapper will only update: >> >> a) Fields that it knows about (i.e. ones I've defined as properties) >> b) Dirty values (i.e. it won't rewrite potentially) stale data >> >> I have defined a Model class for User, just to test this, which >> contains just a handful of the 80 or so columns in the database. >> >> class User >> include DataMapper::Resource >> >> storage_names[:default] = :user >> >> property :id, Serial, :field => 'userid', :key => true >> property :username, String >> property :email, String >> property :activated, Boolean, :field => >> 'isactivated', :default => false >> property :full_name, String, :field => 'fullname', :default >> => '' >> property :password_hash, String, :field => >> 'passwordhash', :default => '' >> property :password_salt, String, :field => 'salt', :default => '' >> property :updated_at, EpochTime, :field => 'timemodified' >> property :logged_in_at, EpochTime, :field => 'timelastlogin' >> property :banned, Boolean, :field => 'isbanned', :default >> => false >> end >> >> Now, I can perform read operations quite happily, which got me all >> excited, but then I tried the next logical thing: create a new user. >> >> new_user = User.new >> new_user.username = 'vssavfvabf' >> new_user.email = '[email protected]' >> new_user.full_name = 'Testing' >> new_user.save >> >> This throws the Exception: >> >> DataObjects::SQLError "Field 'activationcode' doesn't have a default >> value" >> >> Our schema is huge and it pains me to think I may have to work through >> it setting default values for each of the fields that don't have them >> (which is almost all of them, since we just let MySQL set zero or an >> empty string, or NULL if permitted). >> >> But that aside, why is DM even touching this field? Or if it's not, >> what is actually happening and how can I work around it? I know the >> insert will work just fine without specifying a value, since MySQL >> will just use an empty string as a fallback. I'd rather not expressly >> set all the defaults if I can avoid it, since this is an old legacy >> application that has grown into a big hairy beast. If I was designing >> a new schema for a new app I'd not even think twice about it and move >> on, but alas... :) >> >> Any pointers? >> >> Cheers, >> >> Chris >> >> PS: Can I turn something on so that all the queries being executed are >> output or written to a log or some such, for quick and dirty debugging? > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
