dmitriid

dmitriid

One current limitation of the excellent sqlite3 adapter is schemaless queries: Ecto.Adapters.SQLite3 — Ecto SQLite3 v0.24.1

Using schemaless Ecto queries will not work well with SQLite. This is because the Ecto SQLite adapter relies heavily on the schema to support a rich array of Elixir types, despite the fact SQLite only has five storage classes. The query will still work and return data, but you will need to do this mapping on your own.

There’s an open issue to add examples for such mapping: Add examples to documentation for schemaless queries with mappings · Issue #14 · elixir-sqlite/ecto_sqlite3 · GitHub

I was wondering: does any one have examples of how these queries would look? (And these could be added to documentation perhaps)

Showing Posts 1 to 3

dimitarvp

dimitarvp

I’ve thought about this the last year (when I still thought I’ll have time and energy for xqlite) and the only two options I could figure out back then were these:

  1. Utilize SQL comments in the table/view DDLs in the manner described in this SO answer: https://stackoverflow.com/a/7426289/285154. Ideally you’d want this to be DBML or some instance of XML so it absolutely can’t be gotten wrong but really, anything would work.

  2. Have a special table inside your schema a la schema_migrations for Ecto. For my library I am planning to call it xqlite_metadata but I might get bolder and use some more generic naming like sqlite_typing_info. And then you put whatever you like in that table. Of course this has to come with a HUGE WARNING in your docs: “Don’t delete this table or the library won’t work properly!” but what can you do? Developers are, on average, better users than the non-technical people so this should mostly be fine. I mean, I am not seeing people deliberately deleting the schema_migrations table after all.


I am leaning to #2 because, if done well, it can be reused even by other libraries so we could all stop reinventing the same wheels. And if done really well then one day it could be used by sqlite3’s authors to finally start and gradually integrate strict types in the engine. Who knows. It might happen! :slight_smile:

dmitriid

dmitriid OP

Hmmm… I like the idea. But how would then you’d use that in a schemaless query?

Currently when you do a schemaless query with the sqlite3 ecto adapter, it tries to figure out the types and may have weird results

dimitarvp

dimitarvp

Almost exactly like you mentioned. Instead of the library trying to guess the types, it will consult this extra table containing the typing information. It could work.

I never got quite as far as actually implementing it but it was a little over a year ago when I wrote a small prototype in Rust that complemented its rusqlite library and it seemed to work fine on a first glance.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New

Other Trending Topics Top

mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews