lejoko

lejoko

MySQL connector for Ash?

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 ?

First Post! Switch mode

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

Most Liked

lejoko

lejoko

Ok, all tests that came from ash_sqlite are now passing. It should currently work almost like ash_sqlite but without upserts and only when using primary keys generated by ash. Primary keys autogenerated by MySQL (AUTO_INCREMENT) should probably also work but not for bulk insert/update. I’ve not yet added a verifier to enforce those restrictions. Up to now, I’ve worked only on making tests pass, so I’ve not really tested the module in a real app. I’m just now starting to play with it in an app in order to “feel” how it works.

Moreover, I’ve had a look at how ash_postgres does transactions (and custom errors) and it looks like it should be doable with MySQL. Hopefully I’ll be able to add it later. I’ve not yet had a serious look at aggregates.

If my tests go well (and when an official ecto_sql release include my fix) I will probably make a first release. Would you (@zachdaniel) like to have ash_mysql as an “official” part of ash ? After all, it is still mostly your code (from ash_sqlite), my changes are not the biggest part… Anyway, I’ve left almost all of the ash project “branding” that came from ash_sqlite in the repo for now. I’d be happy if it could be “absorbed” officially in the ash project. What is your view on that ? I’m not sure which way to go in this regard.

zachdaniel

zachdaniel

Creator of Ash

So the plan from here will essentially be:

  1. wait for ecto changes to have a stable release
  2. point ash_mysql at those
  3. release the first version, and announce it officially.

Thank you for your excellent work!

lejoko

lejoko

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…

Last Post!

lejoko

lejoko

Exactly. Thank you for Ash! It’s great!

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement