Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Suite #41

Closed
6 tasks done
tyt2y3 opened this issue Jul 9, 2021 · 10 comments · Fixed by #60
Closed
6 tasks done

Test Suite #41

tyt2y3 opened this issue Jul 9, 2021 · 10 comments · Fixed by #60
Assignees

Comments

@tyt2y3
Copy link
Member

tyt2y3 commented Jul 9, 2021

  • create schema online
  • CRUD testing
  • relational query
  • other advanced queries (GROUP BY, etc)
  • sequential operations (read, insert / update, read again and update again)
  • Refactor the test suite such that it can generalizes over Postgres and MySQL (if possible, partially to SQLite)

Ideally the test suite should:

  • cover every SeaORM API
  • multiple cases for each API (has result, no result etc)
  • use more data types (UUID, Decimal, JSON, DateTime, etc)
  • operations that are more complex and 'real world application'
  • runs on SQLite, MySQL & Postgres
@tyt2y3 tyt2y3 mentioned this issue Jul 9, 2021
36 tasks
@tyt2y3 tyt2y3 mentioned this issue Jul 16, 2021
Merged
@samsamai
Copy link
Contributor

Hi @tyt2y3 , I'm not clear about what the task sequential operations means.

@tyt2y3
Copy link
Member Author

tyt2y3 commented Jul 22, 2021

So the idea is to have several test cases with several transactions, for example (me just thinking randomly):

  1. select the baker having the least sales
  2. create and assign more cakes to him
  3. create new order based on the the new baker's cakes
  4. select and verify the result

that is what I mean by 'read, insert / update, read again and update again'

@samsamai
Copy link
Contributor

Hi @tyt2y3 , thanks for the clarification, I've started to implement this but I have run into the same problem that I was asking about in the discussion area. How can I do a query such as this with the ORM:

SELECT
	baker.name, sum(lineitem.price * lineitem.quantity)

FROM
	baker
	INNER JOIN cakes_bakers ON cakes_bakers.baker_id = baker.id
	INNER JOIN cake ON cakes_bakers.cake_id = cake.id
	INNER JOIN lineitem ON lineitem.cake_id = cake.id
GROUP BY
	baker.name;

I don't seem to be able to do multiple joins in one query (for example baker::Entity::find().left_join(cake::Entity) .left_join(lineitem::Entity)) and I haven't been able to find a similar case in the codebase so I'm a bit stuck.

@tyt2y3
Copy link
Member Author

tyt2y3 commented Jul 24, 2021

There is another method in query/helper.rs

    fn join(mut self, join: JoinType, rel: RelationDef) -> Self {
        self.query()
            .join(join, rel.to_tbl.clone(), join_condition(rel));
        self
    }

That does not require a Related trait

@samsamai
Copy link
Contributor

Thanks, got it working now.

@tyt2y3
Copy link
Member Author

tyt2y3 commented Jul 27, 2021

We'd want to refactor our test suite and test for Postgres & SQLite

  1. generalize setup() function to obtain database url from env
  2. extract & generalize any MySQL specific code
  3. make the test suite passes on Postgres
  4. (if no database url passed in from env, fallback to an in memory SQLite database)
    make the test suite passes on SQLite

@samsamai samsamai linked a pull request Aug 4, 2021 that will close this issue
@tyt2y3 tyt2y3 closed this as completed in #60 Aug 7, 2021
@tyt2y3 tyt2y3 reopened this Aug 7, 2021
@tyt2y3
Copy link
Member Author

tyt2y3 commented Aug 7, 2021

@samsamai can you explain what the file pg_tests is for?
Is it duplicate of bakery_chain_tests?

@tyt2y3
Copy link
Member Author

tyt2y3 commented Aug 7, 2021

Oh okay I got it now, Billy added it for testing the driver support.

@samsamai
Copy link
Contributor

samsamai commented Aug 7, 2021

@tyt2y3 pg_tests was done by @billy1624 for when he was working on the pg_driver I think.

@tyt2y3
Copy link
Member Author

tyt2y3 commented Aug 7, 2021

Thank you so much for the great work indeed!

@tyt2y3 tyt2y3 closed this as completed Aug 7, 2021
SebastienGllmt pushed a commit to dcSpark/sea-orm that referenced this issue Apr 13, 2022
* Migrator use reexported `sea_orm::sea_query`

* Bump sea-query version to 0.21.0

* Migrator test case use reexported `sea_orm::sea_query`

* Reexport `sea_orm::sea_query`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants