
Support for DB specific types
Reported by Dan Sully | June 11th, 2008 @ 06:12 PM
#!/usr/bin/env ruby
require 'rubygems'
require 'pp'
require 'data_mapper'
require 'dm-types'
DataMapper.setup(:default, your_config)
- CREATE TABLE tests (
- id int(11) NOT NULL auto_increment,
- status ENUM('crit', 'warn', 'info', 'unknown') default 'unknown',
- PRIMARY KEY (id),
#) TYPE=InnoDB;
- Create a few rows
class Test
include DataMapper::Resource
property :id, Integer, :serial => true
property :status, Enum[:crit, :warn, :info, :unknown]
#property :status, String
end
Test.all.each do |t|
pp t
end
This kind of works if property is a String instead of enum.
Comments and changes to this ticket
-
Bernerd Schaefer June 12th, 2008 @ 10:33 AM
- State changed from new to resolved
This seems to be fixed in the latest git version of dm-core/dm-types.
http://pastie.org/private/ytd7no...
If you're running on the 0.9.0.1 gem, we should be releasing a new gem soon which will include this fix.
-
Bernerd Schaefer June 12th, 2008 @ 11:52 AM
- State changed from resolved to open
Whoops. auto_migrate! doesn't create an ENUM field.
-
Dan Sully June 12th, 2008 @ 12:17 PM
Which, for those of you playing at home means that this isn't fixed and is definitely still a problem (tested again on mysql)
-
Bernerd Schaefer June 13th, 2008 @ 10:39 AM
- Milestone cleared.
- State changed from open to hold
- Title changed from dm-types Enum empty on get to Support for DB specific types
It appears that the primitive type for DM::Enum is Integer, to ensure that it works correctly on all DB's.
Right now we don't have a good way to support database specific types, but we definitely want to add that feature. For the moment, I would suggest changing your status field in the DB to int if possible.
I'm putting this ticket on hold and marking for the 1.x release.
-
Dan Sully June 13th, 2008 @ 11:39 AM
I'm fiddling around with do_mysql_ext.c to see if I can make this go.
How much resistance would there be to having a hardcoded "DM::Types::Enum" const in that code?
-
Carl Lerche June 13th, 2008 @ 12:44 PM
Are there any plans to support Postgres types? Geometry, etc...
-
Bernerd Schaefer June 13th, 2008 @ 02:22 PM
Carl,
I think the idea would be to come up with a system for supporting DB-specific types, and then implement as many of them as people ask for—which would be a few for MySQL, and then a whole lot for Postgres.
-
Dan Kubb (dkubb) December 3rd, 2008 @ 12:24 AM
- Tag set to bug, dm-more, mysql
- Milestone cleared.
- State changed from hold to resolved
- Assigned user cleared.
I'm marking this as resolved because the original ticket reason, that an Enum type be added has been fulfilled.
As far as supporting DB specific types, that's something that is planned.
However, we're trying not to use Lighthouse as a TODO list for future development, as there are much better places to keep track of and discuss features (the mailing list for example). Keeping LH clear of everything aside from actual bugs will allow us to respond more efficiently to real issues.
I would encourage you to bring this up on the mailing list. There are changes that need to happen to DM's internals before this could be made seamless, but it is definitely something I'd like to see supported at some point.
-
Dan Sully December 17th, 2008 @ 09:35 PM
Where is the commit? I'm not seeing any code where I expect to, in do_mysql/ext/
Thanks
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 »