Giter Site home page Giter Site logo

Integration with diesel 2 about sea-query HOT 9 CLOSED

seaql avatar seaql commented on August 16, 2024 1
Integration with diesel 2

from sea-query.

Comments (9)

Sytten avatar Sytten commented on August 16, 2024 1

I was able to make it work in our project because we have a diesel dep, but not in the framework as a macro. Also it uses an older version and I have not updated it to support more recent breaking changes.

from sea-query.

tyt2y3 avatar tyt2y3 commented on August 16, 2024

Two things:

  1. you do not need to generate enums, you can reuse the diesel column structs and derive the Iden trait for them. However I am not aware of a macro-free way to do so.

  2. you can directly use the underlying driver's interface so you don't need to wrap atop Diesel; it'd not be too different from how we are supporting the postgres driver (just a thin wrapper)

Btw, I am never aware of Diesel 2.x, how is it different from 1.x?

Finally, yes if we've figured those things, we could integrate that into SeaQuery

from sea-query.

Sytten avatar Sytten commented on August 16, 2024
  1. Good to know, but yeah since it needs a macro I think it would be easier to just create a new enum. Does working with a struct helps for typing or it is purely for convenience?
  2. Unsure how I would do that, it thought the diesel interface was needed to do the mapping from row to struct.

It changed quite a lot internally, but the main change needed for this feature is the return of the bind function on raw sql can now be boxed so it can run in a loop. In v1 it returns a new type of object so you cant easily loop on it.

from sea-query.

tyt2y3 avatar tyt2y3 commented on August 16, 2024

SeaQuery only requires that a type implements Iden so it can be either struct or enum. I prefer using enum, but struct is fine too. So the advantage is to reuse Diesel's types to reduce the total number of symbols generated.

The crates Diesel use are pq-sys and mysqlclient-sys, but if you want to automatically convert them into the structs, then using Diesel should be slightly easier.

from sea-query.

Sytten avatar Sytten commented on August 16, 2024

I got a working version of the driver for common cases in caido@bd0f734

My only problem is with the JSON, Chrono, etc extensions. I realized that I can't use the cfg inside the macro for that, but I don't have a better idea. I can't do like the sqlx driver since the method when not using the feature returns a bool ref which diesel refuses to take as input to bind.

The need for a macro at all is a bit weird, we could just add diesel as a dependency for the feature and save us a lot of problems.

from sea-query.

tyt2y3 avatar tyt2y3 commented on August 16, 2024

Well, that really seems cool! I never imagined Diesel could be used as a driver.
The problem was discussed in
#15 (comment)
I am not sure if Diesel can be required without any drivers (likely not).
If so, the driver support can be done like postgres which is nicer.

from sea-query.

Sytten avatar Sytten commented on August 16, 2024

Yeah I saw the postgres driver, but I don't think diesel has separate types but if we import the core without any feature it wont pull any driver code. Would that be ok? I am not sure how to do it properly since diesel v2 is not released yet though (probably not for a few months still).

Otherwise I think the best we can do is to document the features that need to be created in the host to enable the support for those extensions.

What is the reasoning for not allowing dependencies on the target inside the sea-query under a feature? I feel that if the ORM doesn't want to have that dependency (because it doesnt need it or what not) then it can just not use the feature and thats it?

from sea-query.

tyt2y3 avatar tyt2y3 commented on August 16, 2024

Hi Emile, just to check in. Have you made any progress in this matter? It's also fine if you have changed your mind.

from sea-query.

tyt2y3 avatar tyt2y3 commented on August 16, 2024

Awesome, nice to know!

from sea-query.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.