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

Add tests against postgres, mysql and sqlite and fixes for #21 #28 #27

Closed
wants to merge 15 commits into from

Conversation

kiddten
Copy link

@kiddten kiddten commented Apr 23, 2019

Related to #21, #28

@kiddten
Copy link
Author

kiddten commented Apr 23, 2019

I've updated PR with fix to issue with NotNullViolationError
Check here https://travis-ci.org/encode/orm/jobs/523425102 for Travis output that discovers that issue

@kiddten
Copy link
Author

kiddten commented Apr 23, 2019

Updated PR with fix for #28

@kiddten
Copy link
Author

kiddten commented Apr 23, 2019

Well updated PR with offset implementation #8

@florimondmanca
Copy link
Member

florimondmanca commented May 8, 2019

@kiddick I think it's great that you found fixes for the various issues you mentioned, but I believe it's better practice to try and submit a different PR for each one, to make the reviewing process easier.

It also makes it easier for others to see if there's already a PR for what they'd like to work on. #38 is redundant with this PR, most likely because @thiagovarela didn't see that this PR fixed #21 too (but one can't tell from the title of this PR, which says it just adds tests). Same for #30 and #32.

I think it might be a good idea to remove the last commits (those about .offset() and .limit()) so that this PR solely focuses on adding tests for Postgres and MySQL, and discuss the other fixes on the existing PRs.

@kiddten
Copy link
Author

kiddten commented May 8, 2019

@florimondmanca well that makes sense
So there is only tests for #21, fix for #21 and fix for #28 since it is needed to tests

@kiddten kiddten changed the title Add tests against postgres, mysql and sqlite Add tests against postgres, mysql and sqlite and fixes for #21 #28 May 8, 2019
before_script:
- psql -c 'create database test_database;' -U postgres
- echo 'create database test_database;' | mysql

script:
- scripts/test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could do something like

script:
    - DATABASE_URL=postgresql://localhost/test_database scripts/test
    - DATABASE_URL=mysql://localhost/test_database scripts/test
    - DATABASE_URL=sqlite:///test.db scripts/test

and then avoid looping through databases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree that this would be a cleaner way to do it.

I'm also concerned that (at first glance at least) there seems to be a lot of code duplication here (either associated with database looping or not).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiddick Yes, I think actually the issue is not the Travis config file but really the duplicated looping. It seems the databases repo uses pytest.mark.parametrize to make that cleaner — see here.

required = [key for key, value in fields.items() if not value.has_default()]
validator = typesystem.Object(
properties=fields, required=required, additional_properties=False
)
kwargs = validator.validate(kwargs)
# remove pk with NULL value to avoid constraint violation in postgres
if pk.allow_null:
del kwargs[pkname]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiddick
I think this will ignore the pk value provided by client.

for example:

class User(orm.Model):
    __tablename__ = "users"

    id = orm.Integer(primary_key=True)
    name = orm.String(max_length=100)


user = await User.objects.create(id=100000001, name="Tom")
assert user.id == 100000001

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add a test for this case in kiddten#1

@aminalaee
Copy link
Member

I guess this is not needed anymore. Thanks for the effort though.

@aminalaee aminalaee closed this Sep 17, 2021
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 this pull request may close these issues.

5 participants