> It looks like the ErlSQL serialization that works for MySQL doesn't
> work for Postgres. Check out erlsql.erl. It may be required to pass it
> an extra 'dialect' parameter that it will use to determine the right
> serialization.

Here's the SQL that's generated:

erlydb_psql:193 INSERT INTO my_model(created_on,name) VALUES  
(20071122142510,'foo');

I am fascinated and horrified that MySQL parses 20071122142510 as a  
timestamp.

Do you know of an easy fix off of the top of your head, or should I  
dive in?




> On Dec 3, 2007 7:37 PM, David King <[EMAIL PROTECTED]> wrote:
>>
>> I have a Postgres table with a timestamp column, like this:
>>
>>  created_on  | timestamp without time zone | not null default now()
>>
>> If I create an instance of this model and let Postgres fill in that
>> column, like this:
>>
>> my_model:save(my_model:new_with([{name,"foo"}])
>>
>> Then it saves, I can look it up with my_model:find_id(Id), etc.
>>
>> However, if I try to specify the created_on column, like this:
>>
>> my_model:save(my_model:new_with([{name,"foo"},
>>
>> {created_on,calendar:universal_time()}])
>>
>> then erlydb_psql returns an error that looks like this:
>>
>> {sql_error,
>>  "42804",
>>  "RupdateTargetListEntry L361 Fparse_target.c HYou will need to
>> rewrite or cast the expression. Mcolumn \"created_on\" is of type
>> timestamp without time zone but expression is of type bigint"}}
>>
>> (note that it does this whether I use the format {{_,_,_},{_,_,_}} or
>> {datetime,{{_,_,_},{_,_,_}}}) This is strange, because
>> erlydb_field:get_erl_type/1 says:
>>
>>   'timestamp without time zone' -> datetime;
>>
>> And the docs for erlydb_field:erlydb_type/1 says:
>>
>> %% @doc Get the field's corresponding Erlang type. Possible values  
>> are
>> %% 'binary', 'integer', 'float', 'date', 'time', and 'datetime'.
>> %%
>> %% Date, time and datetime fields have the following forms:
>> %%
>> %% ```
>> %% {date, {Year, Month, Day}}
>> %% {time, {Hour, Minute, Second}}
>> %% {datetime, {{Year, Month, Day}, {Hour, Minute, Second}}}
>>
>> Any ideas on why I can't specify this column?
>>
>>>
>>
>
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"erlyweb" 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/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to