Comments (9)
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.
Two things:
-
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. -
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.
- 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?
- 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.
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.
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.
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.
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.
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.
Awesome, nice to know!
from sea-query.
Related Issues (20)
- Do typechecking on postgres value binder (implement `accepts`) HOT 1
- Multiple arguments / multiple parameters on custom postgres function breaking with Func::cust().args()
- Double paren causes SQL error when using `IN` operator HOT 3
- syn 1.x and 2.x both used in sea-query HOT 2
- CaseStatement has no aggregate functions HOT 2
- Supporting a new type in SeaQuery
- Macro for generating the Iden from a given Struct HOT 6
- sea-query's implementation for .limit(1) destroys performance on pg 12 HOT 6
- enum_def could derive IdenStatic HOT 1
- postgres: Support creating partitioned tables
- postgres: bulk insert API with UNNEST and ARRAYs HOT 4
- postgres: `CAST($2 AS CaseSensitiveEnumType)` enum type must be enquoted
- sea-query-rusqlite - rusqlite 0.30 is not supported by sea-query-rusqlite version 0.4 HOT 2
- postgres: silently uses signed integers when unsigned integers are specified in schema HOT 2
- `Table::drop()` with multiple `.table` when using sqlite3 causes invalid sql
- Add support for `Arc<str>` value
- Error running sqlx_any in example after upgrading sqlx to 0.7 HOT 1
- rusqlite - bundled forces static linkage HOT 2
- Postgres: Support creating functional indexes HOT 1
- All index hints appear after the last `from` statement
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sea-query.