ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ur5us has quit [Ping timeout: 250 seconds]
ur5us has joined #crystal-lang
<wwalker> roflmao
Sankalp has quit [Ping timeout: 246 seconds]
Sankalp has joined #crystal-lang
ur5us has quit [Ping timeout: 250 seconds]
jmdaemon has quit [Ping timeout: 252 seconds]
casionaut has joined #crystal-lang
<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.
<frojnd> @Blacksmoke16: this is how table looks like: https://termbin.com/uwxd and this is the sql I'm trying to execute: https://termbin.com/2j2a
<FromGitter> <Blacksmoke16> i think you should update your SQL to specify what fields you're inserting
<frojnd> @Blacksmoke16 like starting with $2 ?
<FromGitter> <Blacksmoke16> i.e. it thinks you're going in order and `$1` maps to `id` which fails since its a string
<FromGitter> <Blacksmoke16> `insert into app (name, package, version_code, version_name, md5) values ($1, $2, $3, $4, $5)`
Sankalp has quit [Ping timeout: 256 seconds]
<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?
<frojnd> Yes
<FromGitter> <Blacksmoke16> i think you need to add the list *before* the `values` keyword
<casionaut> Blacksmoke16: Good to know that another book is coming. Any other resources you'd recommend for the meanwhile?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/1.4/
<casionaut> Blacksmoke16: cheers
casionaut has quit [Quit: Client closed]
slightlypandaish has joined #crystal-lang
analog_salad has joined #crystal-lang
analogsalad has quit [Ping timeout: 240 seconds]
analog_salad has quit [Quit: bye]
analogsalad has joined #crystal-lang
slightlypandaish has quit [Quit: Client closed]
analogsalad has quit [Quit: bye]
ur5us has joined #crystal-lang
jmdaemon has joined #crystal-lang
jmd_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 252 seconds]