
Using default values with Enum
Reported by jonuts | June 14th, 2010 @ 10:32 AM
I am running into what looks like a bug in dm-migrations using Enum type with :default option. I tested on mysql and sqlite. Sqlite does not seem to be affected for some reason.
Here is what I am doing: http://gist.github.com/437741
Followed by this error: Invalid default value for 'hello'
(DataObjects::SQLError)' (full stacktrace:
http://gist.github.com/437747)
I patched lib/dm-migrations/adapters/dm-do-adapter.rb
(attached), and it looks like everything is working. I
think the real patch would be to use if
property.respond_to?(:dump)
instead of using it in an
elsif
, as Property.type looks unused, but this works
and was less scary..
Comments and changes to this ticket
-
jonuts June 14th, 2010 @ 11:34 AM
- Tag set to 1.0, default, dm-migrations, dm-types, enum
Couple of things: I'm using dm 1.0. Also, I see now that I meant
Property#type
above.. -
jonuts June 16th, 2010 @ 11:48 PM
Dup of http://datamapper.lighthouseapp.com/projects/20609/tickets/1306. Fixed in 'next'
-
Dan Kubb (dkubb) September 2nd, 2010 @ 01:22 PM
- State changed from new to resolved
- Milestone order changed from 0 to 0
(from [27c750636cbb9eec00fc0b75a0c1735deb4643bd]) Fixed default values to pass through Property#dump for DDL statements
- This fixes various problems with Flag and Enum properties, among others, where the value that is provided in the :default option was used directly in the DDL statement. While this works when the ruby value maps onto the database column type, it does not work when Property#dump converts the value into another representation.
[#1306 state:resolved] [#1320 state:resolved] [#1356 state:resolved] http://github.com/datamapper/dm-migrations/commit/27c750636cbb9eec0...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Attachments
Tags
Referenced by
-
1356 Defaults in enums don't work with ORACLE [#1306 state:resolved] [#1320 state:resolved] [#1356 stat...
-
1320 Using default values with Enum [#1306 state:resolved] [#1320 state:resolved] [#1356 stat...
-
1306 auto_upgrade for Enum/Flag proporties fails [#1306 state:resolved] [#1320 state:resolved] [#1356 stat...