sql

m3tti 2024-10-07T12:06:37.372669Z

if i have date values that has to be inserted into the database wth honeysql what do i have to do than?

igrishaev 2024-10-07T12:10:29.930489Z

Just pass them into parameters as usual. Dates are natively supported by jdbc.

m3tti 2024-10-07T12:11:08.306059Z

hrm strange i get the following issue

ERROR: column "end_date" is of type date but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.
  Position: 181

m3tti 2024-10-07T12:12:14.673529Z

end date is transfered from my form

end_date "2024-10-08"

igrishaev 2024-10-07T12:13:37.346439Z

it means, you have date column in the db, but you pass a string. Either coerce string into Date, or LocalDate object, or use ::date coercion in your sql

m3tti 2024-10-07T12:18:18.013979Z

so it should be sufficient to use the string and create a date object out of it right

p-himik 2024-10-07T12:19:13.047889Z

If the string has all the relevant data - yes. And since your question is about HoneySQL (BTW there's #honeysql), you can do the cast with [:cast the-value :date].

m3tti 2024-10-07T12:19:39.808739Z

ok but it would be simple i guess converting the value directly

p-himik 2024-10-07T12:20:44.887839Z

Depends on what you mean by "simple". :) If your connection is HTTP, dates will be converted to strings anyway, as far as I'm aware.

m3tti 2024-10-07T12:36:43.717859Z

Exactly like that i wanted to grep the form params and assoc new values to the date fields by using LocalDate/parse on the given string from the params