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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews