sea-query icon indicating copy to clipboard operation
sea-query copied to clipboard

fix #420

Open baoyachi opened this issue 3 years ago • 5 comments

fix #420

Then, sea-orm call sea-query crate, not always use Object owership with use sea_query::{MysqlQueryBuilder, PostgresQueryBuilder, SqliteQueryBuilder};

baoyachi avatar Aug 16 '22 09:08 baoyachi

From API ergonomic point of view: I favour XxxQueryBuilder over &XxxQueryBuilder

billy1624 avatar Aug 16 '22 12:08 billy1624

Hey @baoyachi, thanks for the contributions!!

XxxQueryBuilder is just a unit struct that serve as a construct to mark which db backend is it. Is it a performance consideration to pass by reference instead of consuming (owning) it?

I doubt there is any practical performance gain @tyt2y3

Two part:

  • not always create new XXXBuilder
  • When I wanted to extend sea-orm, I found that it could not be extended. The key code could not be called because this is a built-in enumeration type.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DbBackend {
    /// A MySQL backend
    MySql,
    /// A PostgreSQL backend
    Postgres,
    /// A SQLite backend
    Sqlite,
}

The limit code :

 pub fn exec<'a, C>(self, db: &'a C) -> impl Future<Output = Result<XXXResult<A>, DbErr>> + '_
    where
        C: ConnectionTrait,
        A: 'a,
    {
+        let builder = db.get_database_backend();
        exec_insert(self.primary_key, builder.build(&self.query), db)
    }

let builder = db.get_database_backend(); The builder return DbBackend,

  • Now it is changed to a reference structure. I can extend the trait to the interior of sea-query. The dependency is coupled

baoyachi avatar Aug 16 '22 12:08 baoyachi

@billy1624 I can modify it slightly so that both parameters XxxQueryBuilder and ref XxxQueryBuilder can be accepted

baoyachi avatar Aug 17 '22 09:08 baoyachi

@billy1624 I can modify it slightly so that both parameters XxxQueryBuilder and ref XxxQueryBuilder can be accepted

That would be great! That way, it's backward compatible :)

billy1624 avatar Aug 19 '22 04:08 billy1624

@baoyachi hello. Do you want to continue work in this PR?

ikrivosheev avatar Sep 19 '22 10:09 ikrivosheev

A month has passed without a response, I close.

ikrivosheev avatar Oct 21 '22 09:10 ikrivosheev