lejoko

lejoko

Hi,

I work for a small MVNO and I’m very much interested to try using Ash in our internal devs. However I have a (probably) breaking requirement : I need to be able to connect it to our MySQL 8.0 (Actually Percona XtraDB) cluster. Is there something in the making ? I heard about that in the past, but did not found anything up to now.
I might be interested in having a try at making a MySQL connector myself, but I’m not sure where should I start ?

Showing Posts 1 to 10

zachdaniel

zachdaniel

Creator of Ash

:wave: Work has been made in that direction, but MySQL itself has not been done. The best way to move forward with that would be to copy ash_sqlite into ash_mysql and start making modifications to get the tests passing. What will likely additionally need to happen is that the AshSql implementation will need to be expanded to account for whatever special thing isn’t supported by

lejoko

lejoko OP

Thanks for your answer. I started trying from a copy of ash_sqlite like you suggested and I’ve hit a problem that I’m not sure how to solve : 89 tests on 115 fail because :

* ** (ArgumentError) :returning is not supported in insert/insert_all by MySQL

What do you use it for ? Do you have an idea how may I work around that ?

zachdaniel

zachdaniel

Creator of Ash

You can try removing it, we use it to get the result of the insert to return. It could be replaced with reading the inserted record again? Does SQLite return that info automatically perhaps?

lejoko

lejoko OP

MySQL does not have a way to return the result of an insert. It returns only the number of inserted records.

If you rely on auto generated primary keys (AUTO_INCREMENT in MySQL terms, which is the default for most people), there is a way to get it back wit a call to the LAST_INSERT_ID() function; You could then load the record back. However that would work only for an insert of a single record. For bulk inserts, that function returns only the id of the first inserted record, and there is no reliable way to get the ids of the other records (they might be guessable in simple cases, but it would break in a lot of clustering configs).

The only way around that would be to generate the primary key on the app side and load the records afterward or to not rely on that ability…

zachdaniel

zachdaniel

Creator of Ash

There is a fair amount of stuff in ash that depends on being able to get the results of a creation currently. So what we will have to do is add a capability for data layers, like return_from_create, and then if they can’t do that, we’ll have to disable certain capabilities, like after_action hooks.

lejoko

lejoko OP

For tables where the primary key is ecto generated (isn’t it the default in ash?), wouldn’t it be possible to “fake” the :returning option ?

zachdaniel

zachdaniel

Creator of Ash

Yes, we could definitely do that :slight_smile: They aren’t ecto generated, but they are generated in Ash by default. Basically requiring that all primary attributes have a default configured could get us started. Then we could support auto incrementing integers later, but require that you can’t do certain things in create actions.

lejoko

lejoko OP

Soooo… As you suggested, I copied ash_sqlite and had a first try at an ash_mysql datalayer. It is far from finished : i have 35 failures on the 115 tests that came from ash_sqlite, and several hard coded parts that need to be properly finished/rewritten.

It’s available here : GitHub - ash-project/ash_mysql · GitHub

I’m having a bit of a hard time with it, since I’m an Ash rookie and in a lot of cases I’m not too sure of what would be the “right way” to do something. I’d be really happy if I could have some guiding to continue on that project because I really like Ash and would like to be able to use it at work!

zachdaniel

zachdaniel

Creator of Ash

Nice! I will take a look in the next few days.

kamaroly

kamaroly

Super!

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews