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 joined #crystal-lang
hightower2 has joined #crystal-lang
ur5us_ has quit [Ping timeout: 245 seconds]
<FromGitter> <neatorobito> Windows
hightower2 has quit [Ping timeout: 250 seconds]
hightower2 has joined #crystal-lang
notzmv has quit [Ping timeout: 268 seconds]
<frojnd> hM
<frojnd> I have trouble figuring out how to use prepared statement inside json_replace (sqlite) statement. I would like to replace `#{title}'` with prepared statement for following example: data = db.scalar "select json_replace(meditation, '$.blog_title', '#{title}') from dailymeditation where date == DATE(?)", date_s.as(String)
<frojnd> My title won't work and I get sqlite exception if title String has `'` inside
<frojnd> So I need to prepared statement similar as to DATE(?)
<straight-shoota> frojnd, yeah I would always recommend to use variable substitution. Don't even think about string interpolation inside SQL query (unless you need to modify the query itself).
<straight-shoota> Just replace `#{title}` by another `?` and insert that parameter before the date value
<straight-shoota> sry, need to replace `'#{title}'` (including single quotes=
<frojnd> straight-shoota: `data = db.scalar "select json_replace(meditation, '$.blog_title', '?') from dailymeditation where date == DATE(?)", title.as(String), date_s.as(String)` gives me: Unhandled exception: column index out of range (SQLite3::Exception)
<straight-shoota> lose the quotes around `?`
<frojnd> Aha without single quotes!
<frojnd> Thank you
<FromGitter> <asterite> Ali: right, Proc doesn't work with varadic args, and it never will. It will also never support named arguments. I would try to avoid Proc unless absolutely necessary. The main reason Proc exists is to capture callbacks.
<frojnd> I have some refactoring to do to ditch interpolations
cfebs_ has joined #crystal-lang
Stephie- has joined #crystal-lang
fifr_ has joined #crystal-lang
dannyAAM_ has joined #crystal-lang
nullsec has joined #crystal-lang
brw6 has joined #crystal-lang
peer has quit [Ping timeout: 260 seconds]
spuun has quit [Ping timeout: 260 seconds]
nullsec is now known as peer
fifr has quit [Ping timeout: 260 seconds]
cfebs has quit [Ping timeout: 260 seconds]
brw has quit [Ping timeout: 260 seconds]
Stephie has quit [Ping timeout: 260 seconds]
wmoxam has quit [Ping timeout: 260 seconds]
dannyAAM has quit [Ping timeout: 260 seconds]
cfebs_ is now known as cfebs
brw6 is now known as brw
dannyAAM_ is now known as dannyAAM
spuun has joined #crystal-lang
wmoxam has joined #crystal-lang
notzmv has joined #crystal-lang
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
<frojnd> I defined and array empty one: `data_a = Array(String).new`
<frojnd> I then would like to store some data from DB: `data_a << db.scalar "select json_extract(meditation, '$.verse_id', '$.blog_title') from dailymeditation where date == DATE(?)", date_s.as(String)` But I get Error: no overload matches 'Array(String)#<<' with type (Float64 | Int64 | Slice(UInt8) | String | Nil)
<frojnd> My question is, do I know what kind of type would be from that select statement during compile time?
<frojnd> Obviously crystal wants it to be String but DB apparently didn't decide yet what kind of data will return?
<frojnd> I _know_ that data from DB should be String. But at compile time compiler doesn't know that yet?
<FromGitter> <Dan-Do> You can do `.to_s` or `.as(String)`
HumanG33k has quit [Ping timeout: 264 seconds]
HumanG33k has joined #crystal-lang
<FromGitter> <naqvis> > Ali: right, Proc doesn't work with varadic args, and it never will. It will also never support named arguments. I would try to avoid Proc unless absolutely necessary. The main reason Proc exists is to capture callbacks. ⏎ ⏎ Thanks Ary. I used Proc for callbacks as well. I do try to avoid them where possible, but sometimes need arrive to have that functionality
<FromGitter> <jwaldrip:matrix.org> I am getting the following when trying to run crystal statically linked from scratch
<FromGitter> <jwaldrip:matrix.org> ``````
<FromGitter> <jwaldrip:matrix.org> My docker file looks like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=61a111b675fa481649573f98]
<FromGitter> <Blacksmoke16> based on https://pkgs.alpinelinux.org/contents?repo=main&page=1&arch=x86&branch=v3.3&name=ca-certificates, the certs are stored in `/usr/share/ca-certificates/`
<FromGitter> <Blacksmoke16> hmm, but other blob posts and such seem to suggest what you have is correct
<FromGitter> <jwaldrip:matrix.org> where does crystal look for the certs by default?
<FromGitter> <Blacksmoke16> im not sure, i imagine its handled by openssl?
<FromGitter> <Blacksmoke16> imo id just use a fresh alpine image as the base. still only a few mb and you get a filesystem, package manager, etc built in if ever needed
<FromGitter> <jwaldrip:matrix.org> I figured it out
<FromGitter> <Blacksmoke16> nice! what was it?
<FromGitter> <jwaldrip:matrix.org> the newest image stores it in `/etc/ssl1.1`
<FromGitter> <jwaldrip:matrix.org> which you can get from `RUN openssl version -d`
<FromGitter> <Blacksmoke16> ah easy enough
<FromGitter> <jwaldrip:matrix.org> looks like alpine doesnt have openssl3 yet
<FromGitter> <Blacksmoke16> even when using the actual alpine image not the crystal one?
<FromGitter> <jwaldrip:matrix.org> openssl3 isnt on their package site
<FromGitter> <jwaldrip:matrix.org> its all 1.1
<FromGitter> <Blacksmoke16> ahh gotcha
<SamantazFox> <jwaldrip> "looks like alpine doesnt have openssl3 yet" <- They tried to go with OpenSSL 3, but too many things were depending on OpenSSL 1.1 APIs and they weren't able to finish the migration
<SamantazFox> They are also looking forward into moving to LibreSSL
ur5us_ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 250 seconds]
<FromGitter> <paulocoghi> *offtopic:* Is LibreSSl ready for Quic? For me, it seems that BoringSSL would be a better option
ur5us_ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 240 seconds]
<straight-shoota> It's also in 3.15
<straight-shoota> Alpine didn't move to make OpenSSL 3 the default, but it's available in the package sources if you want to install it. We're actually using that in Crystal CI
ur5us_ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 265 seconds]