That did it.

Thanks so much!

On Thursday, August 30, 2018 at 4:13:23 PM UTC-7, Jeremy Evans wrote:
>
>
>
> On Thursday, August 30, 2018 at 3:48:34 PM UTC-7, Joseph Kowalski wrote:
>>
>> As a follow up:
>> I've implemented this in my code as follows:
>> array_of_arrays = [[123456, Date.iso8601('2018-08-15')], 
>>                    [123457, Date.iso8601('2018-08-15')],
>>                    [123458, Date.iso8601('2018-08-15')]]
>>   DB.from(Sequel[:services].as(:svcs), DB.values(array_of_arrays).
>>       as(:updsvcs, [:sid, :new_billed_through])).
>>       where{svcs[:service_id] =~ updsvcs[:sid]}.
>>       update( :billed_through => Sequel[:updsvcs][:new_billed_through])
>>
>> I'm having trouble with this however as one of the fields in my actual 
>> code and DB is a date field. However when it's turned into a 'value', the 
>> data is turned into text (I think that's when this happens) as I get the 
>> following error on insert:
>> PG::DatatypeMismatch: ERROR:  column "billed_through" is of type date 
>> but expression is of type text
>>
>> The DB logger shows the following resulting output (I've replace the 
>> actual data with my dummy array of arrays as above and cleaned up the 
>> formatting)
>> E, [2018-08-30T15:39:54.660212 #24068] ERROR -- : PG::DatatypeMismatch: 
>> ERROR: 
>> column "billed_through" is of type date but expression is of type text
>> LINE 1: ...PDATE "services" AS "svcs" SET "billed_through" = "updsvcs"....
>>                                                              ^
>> HINT:  You will need to rewrite or cast the expression.: 
>> UPDATE "services" AS "svcs" 
>> SET "billed_through" = "updsvcs"."new_billed_through" 
>> FROM (VALUES (123456, '2018-08-15'), 
>>              (123457, '2018-08-15'),
>>              (123458, '2018-08-15')) AS "updsvcs"("sid", 
>> "new_billed_through") 
>> WHERE ("svcs"."service_id" = "updsvcs"."sid")
>>
>> Is there a way to cast that value as a date that Postgres will accept for 
>> that field?
>>
>>
> You can probably do:
>
> Sequel[:updsvcs][:new_billed_through].cast(Date)
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to