M
Martin DeMello
I'm investigating the use of DataMapper to convert an old project with
handwritten sql into something a bit more maintainable. Writing the
model mappings etc. was quick and easy, then I ran into the following
issue: I had a field defined as a timestamp in postgresql, and the old
code was passing it a string in the insert statement. I accidentally
passed the string to DataMapper, so I had something like
model.newname => foo, :modified => datestring)
instead of
model.newname => foo, :modified => date)
The problem was that DataMapper simply returned false when I tried
saving it, with no indication of what had failed. Turning on verbose
sql logging revealed that it didn't even attempt to create the INSERT
statement (which is fair enough). It took me roughly an hour to
discover my mistake. I then spent another hour poking around the DM
documentation and API, searching for the debugging technique that
would have let me catch my original mistake quickly and easily, and
have come up blank.
Is DataMapper really that unhelpful, or am I doing something wrong? Is
Sequel any better in this regard? If I do switch to Sequel, is the
model support as good as DataMapper's?
martin
handwritten sql into something a bit more maintainable. Writing the
model mappings etc. was quick and easy, then I ran into the following
issue: I had a field defined as a timestamp in postgresql, and the old
code was passing it a string in the insert statement. I accidentally
passed the string to DataMapper, so I had something like
model.newname => foo, :modified => datestring)
instead of
model.newname => foo, :modified => date)
The problem was that DataMapper simply returned false when I tried
saving it, with no indication of what had failed. Turning on verbose
sql logging revealed that it didn't even attempt to create the INSERT
statement (which is fair enough). It took me roughly an hour to
discover my mistake. I then spent another hour poking around the DM
documentation and API, searching for the debugging technique that
would have let me catch my original mistake quickly and easily, and
have come up blank.
Is DataMapper really that unhelpful, or am I doing something wrong? Is
Sequel any better in this regard? If I do switch to Sequel, is the
model support as good as DataMapper's?
martin