<casionaut>
Has anyone read "programming crystal" book recently? I wonder if it's outdated or not.
slightlypandaish has joined #crystal-lang
slightlypandaish has quit [Quit: Client closed]
analogsalad has joined #crystal-lang
casionaut has quit [Quit: Client closed]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
<frojnd>
Hm
<frojnd>
My id inside table is defined like this: `id | integer | | not null | nextval('app_id_seq'::regclass)` so when inserting stuff for the table I can ommit id part. But in Crystal, I have to specify id inside insert statement. Why is that?
<FromGitter>
<Blacksmoke16> casionaut: i hear theres another one coming out in another month or two, could just wait for that one
<FromGitter>
<Blacksmoke16> think you can also find a PDF of the first one online too
<FromGitter>
<Blacksmoke16> whats the error you get if you dont
<analogsalad>
Blacksmoke16: A new edition of that book or a different one?
<FromGitter>
<Blacksmoke16> different one
<frojnd>
@Blacksmoke16: Unhandled exception: invalid input syntax for type integer: "foo.bar" (PQ::PQError)
<FromGitter>
<Blacksmoke16> and whats your sql look like?
<analogsalad>
Blacksmoke16: good to know, thanks. I was also looking for a book.
<analogsalad>
"Programming Crystal" was written at v0.27.0. It's probably better to wait for the new one.
<FromGitter>
<Blacksmoke16> https://www.postgresql.org/docs/current/sql-insert.html ⏎ ⏎ > The target column names can be listed in any order. If no list of column names is given at all, the default is all the columns of the table in their declared order; or the first N column names, if there are only N columns supplied by the VALUES clause or query. The values supplied by the VALUES clause or query are associated with the
<FromGitter>
... explicit or implicit column list left-to-right.
<frojnd>
I see
<frojnd>
Thank you
<frojnd>
Hm
<frojnd>
Can I insert such statement directly in Crystal?
<frojnd>
It works in psql shell but not sure how to do it in Crystal
<FromGitter>
<Blacksmoke16> literally just add the column list to your insert query
<frojnd>
Aha ok
Sankalp has joined #crystal-lang
<frojnd>
`db.exec "insert into app values (package, version_code, version_name, md5)", "foo.bar", 3, "1235", "219asdf23"` gives me: `Unhandled exception: column "package" does not exist (PQ::PQError)`
casionaut has joined #crystal-lang
<FromGitter>
<Blacksmoke16> does your table have a `package` column?