-module(cake@adapter@sqlite). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([with_connection/2, with_memory_connection/1, read_query_to_prepared_statement/1, write_query_to_prepared_statement/1, execute_raw_sql/2, run_read_query/3, run_write_query/3, run_query/3]). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 21). -spec with_connection(binary(), fun((sqlight:connection()) -> QIQ)) -> QIQ. with_connection(Filename, Callback) -> sqlight:with_connection(<<"file:"/utf8, Filename/binary>>, Callback). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 32). -spec with_memory_connection(fun((sqlight:connection()) -> QIR)) -> QIR. with_memory_connection(Callback) -> sqlight:with_connection(<<":memory:"/utf8>>, Callback). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 38). -spec read_query_to_prepared_statement(cake@internal@read_query:read_query()) -> cake@internal@prepared_statement:prepared_statement(). read_query_to_prepared_statement(Query) -> _pipe = Query, cake@dialect@sqlite_dialect:read_query_to_prepared_statement(_pipe). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 46). -spec write_query_to_prepared_statement( cake@internal@write_query:write_query(any()) ) -> cake@internal@prepared_statement:prepared_statement(). write_query_to_prepared_statement(Query) -> _pipe = Query, cake@dialect@sqlite_dialect:write_query_to_prepared_statement(_pipe). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 107). -spec execute_raw_sql(binary(), sqlight:connection()) -> {ok, nil} | {error, sqlight:error()}. execute_raw_sql(Sql_string, Db_connection) -> _pipe = Sql_string, sqlight:exec(_pipe, Db_connection). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 114). -spec cake_param_to_client_param(cake@param:param()) -> sqlight:value(). cake_param_to_client_param(Param) -> case Param of {bool_param, Param@1} -> sqlight:bool(Param@1); {float_param, Param@2} -> sqlight:float(Param@2); {int_param, Param@3} -> sqlight:int(Param@3); {string_param, Param@4} -> sqlight:text(Param@4); null_param -> sqlight_ffi:null() end. -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 54). -spec run_read_query( cake@internal@read_query:read_query(), fun((gleam@dynamic:dynamic_()) -> {ok, QIU} | {error, list(gleam@dynamic:decode_error())}), sqlight:connection() ) -> {ok, list(QIU)} | {error, sqlight:error()}. run_read_query(Query, Decoder, Db_connection) -> Prepared_statement = begin _pipe = Query, read_query_to_prepared_statement(_pipe) end, Sql_string = begin _pipe@1 = Prepared_statement, cake:get_sql(_pipe@1) end, Db_params = begin _pipe@2 = Prepared_statement, _pipe@3 = cake:get_params(_pipe@2), gleam@list:map(_pipe@3, fun cake_param_to_client_param/1) end, _pipe@4 = Sql_string, sqlight:'query'(_pipe@4, Db_connection, Db_params, Decoder). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 72). -spec run_write_query( cake@internal@write_query:write_query(QJB), fun((gleam@dynamic:dynamic_()) -> {ok, QJB} | {error, list(gleam@dynamic:decode_error())}), sqlight:connection() ) -> {ok, list(QJB)} | {error, sqlight:error()}. run_write_query(Query, Decoder, Db_connection) -> Prepared_statement = begin _pipe = Query, write_query_to_prepared_statement(_pipe) end, Sql_string = begin _pipe@1 = Prepared_statement, cake:get_sql(_pipe@1) end, Db_params = begin _pipe@2 = Prepared_statement, _pipe@3 = cake:get_params(_pipe@2), gleam@list:map(_pipe@3, fun cake_param_to_client_param/1) end, _pipe@4 = Sql_string, sqlight:'query'(_pipe@4, Db_connection, Db_params, Decoder). -file("/Volumes/Gleam/gleam-cake-sqlight/src/cake/adapter/sqlite.gleam", 92). -spec run_query( cake:cake_query(QJJ), fun((gleam@dynamic:dynamic_()) -> {ok, QJJ} | {error, list(gleam@dynamic:decode_error())}), sqlight:connection() ) -> {ok, list(QJJ)} | {error, sqlight:error()}. run_query(Query, Decoder, Db_connection) -> case Query of {cake_read_query, Read_query} -> _pipe = Read_query, run_read_query(_pipe, Decoder, Db_connection); {cake_write_query, Write_query} -> _pipe@1 = Write_query, run_write_query(_pipe@1, Decoder, Db_connection) end.