Giter VIP home page Giter VIP logo

Comments (11)

tyt2y3 avatar tyt2y3 commented on September 6, 2024 1

Okay, good to know. Thanks.

from sea-orm.

tyt2y3 avatar tyt2y3 commented on September 6, 2024 1

@billy1624 can we also run our test suite using tokio?

from sea-orm.

tyt2y3 avatar tyt2y3 commented on September 6, 2024

Can you setup an minimal reproducible example under /examples?

from sea-orm.

tqwewe avatar tqwewe commented on September 6, 2024

I've fixed it locally... the quick fix seems to be changing the definition of trait Iden in sea-query to:

pub trait Iden: Send + Sync {
    ...
}

This is to enforce the type is Sync

from sea-orm.

tyt2y3 avatar tyt2y3 commented on September 6, 2024

Great finding. Can we instead do it inside SeaORM, changing IdenStatic instead of Iden?

pub trait IdenStatic: Iden + Copy + Debug + Send + Sync + 'static {

I am trying to understand the problem

from sea-orm.

tqwewe avatar tqwewe commented on September 6, 2024

I've tried removing Send + Sync from Iden trait in sea-query and adding it to IdenStatic like you suggested, but the errors come back.

T inside Arc<T> should be Send + Sync for the whole Arc to be Send + Sync.
https://doc.rust-lang.org/std/sync/struct.Arc.html#thread-safety
It says:

Arc<T> will implement Send and Sync as long as the T implements Send and Sync. Why can’t you put a non-thread-safe type T in an Arc<T> to make it thread-safe? This may be a bit counter-intuitive at first: after all, isn’t the point of Arc<T> thread safety? The key is this: Arc<T> makes it thread safe to have multiple ownership of the same data, but it doesn’t add thread safety to its data.

Perhaps sea-query should add Send + Sync to the Iden trait only if "thread-safe" flag is enabled.

from sea-orm.

tyt2y3 avatar tyt2y3 commented on September 6, 2024

Btw, any idea how can I add a test case to our test suite for this?
Because it worked in our async_std examples.
It might be specific to tokio?

from sea-orm.

tqwewe avatar tqwewe commented on September 6, 2024

Btw, any idea how can I add a test case to our test suite for this?

Perhaps just making a tokio app and executing your query in a tokio spawned task:

tokio::spawn(async move {
    MyEntity::find().one(&db).await;
})
.await;

It might be specific to tokio?

Perhaps... but I think it might just be any app that uses multiple threads.

from sea-orm.

billy1624 avatar billy1624 commented on September 6, 2024

Planning to do so. Running doctest & unit test on all supported runtime.

from sea-orm.

billy1624 avatar billy1624 commented on September 6, 2024

Planning to do so. Running doctest & unit test on all supported runtime.

See #91

from sea-orm.

tyt2y3 avatar tyt2y3 commented on September 6, 2024

I verified that enabling thread-safe on SeaQuery did solve the issue.

from sea-orm.

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.