Skip to content
New issue

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

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

Already on GitHub? # to your account

Put schema in quotes for postgres driver #2436

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

TwoDCube
Copy link
Contributor

@TwoDCube TwoDCube commented Dec 2, 2024

PR Info

Previously if the schema contained special characters like a -, the pool connection would end up timing out because of a syntax error. This PR fixes that syntax error.

Bug Fixes

  • Put schema in quotes for postgres driver to avoid pool timeout

Testing

Testing without the fix
running 3 tests
test connection_with_search_path_postgres ... FAILED
test connection_ping ... ok
test connection_ping_closed_postgres ... ok

failures:

---- connection_with_search_path_postgres stdout ----
2024-12-02T19:22:42.419895Z DEBUG sea_orm::driver::sqlx_postgres: DROP DATABASE IF EXISTS "connection_with_search_path";
2024-12-02T19:22:42.466817Z  INFO sqlx::query: summary="DROP DATABASE IF EXISTS ?" db.statement="\n\nDROP DATABASE IF EXISTS \"connection_with_search_path\";\n" rows_affected=0 rows_returned=0 elapsed=46.401339ms elapsed_secs=0.046401339
2024-12-02T19:22:42.466876Z DEBUG sea_orm::driver::sqlx_postgres: CREATE DATABASE "connection_with_search_path";
2024-12-02T19:22:43.108721Z  INFO sqlx::query: summary="CREATE DATABASE \"connection_with_search_path\";" db.statement="" rows_affected=0 rows_returned=0 elapsed=638.679744ms elapsed_secs=0.638679744
2024-12-02T19:22:43.116010Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=148.692�s elapsed_secs=0.000148692
2024-12-02T19:22:43.116044Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:43.128712Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=127.322�s elapsed_secs=0.000127322
2024-12-02T19:22:43.128738Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:43.151358Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=132.771�s elapsed_secs=0.000132771
2024-12-02T19:22:43.151385Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:43.193870Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=136.452�s elapsed_secs=0.000136452
2024-12-02T19:22:43.193889Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:43.276628Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=133.041�s elapsed_secs=0.000133041
2024-12-02T19:22:43.276652Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:43.439706Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=162.842�s elapsed_secs=0.000162842
2024-12-02T19:22:43.439728Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:43.770655Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=137.072�s elapsed_secs=0.000137072
2024-12-02T19:22:43.770697Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:44.174110Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=170.962�s elapsed_secs=0.000170962
2024-12-02T19:22:44.174150Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:44.577472Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=153.511�s elapsed_secs=0.000153511
2024-12-02T19:22:44.577511Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
2024-12-02T19:22:44.980738Z  INFO sqlx::query: summary="SET search_path = schema-with-special-characters" db.statement="" rows_affected=0 rows_returned=0 elapsed=135.862�s elapsed_secs=0.000135862
2024-12-02T19:22:44.980774Z ERROR sqlx_core::pool::inner: error returned from after_connect error=error returned from database: syntax error at or near "-"
thread 'connection_with_search_path_postgres' panicked at tests/connection_tests.rs:159:5:
assertion failed: db.is_ok()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    connection_with_search_path_postgres

test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 8.72s

error: test failed, to rerun pass `--test connection_tests`
Testing with the fix
running 3 tests
test connection_with_search_path_postgres ... ok
test connection_ping ... ok
test connection_ping_closed_postgres ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 8.80s

Copy link
Member

@tyt2y3 tyt2y3 left a comment

Choose a reason for hiding this comment

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

thank you!

@tyt2y3 tyt2y3 merged commit e27e1d9 into SeaQL:master Dec 23, 2024
29 checks passed
Copy link

🎉 Released In 1.1.3 🎉

Thank you everyone for the contribution!
This feature is now available in the latest release. Now is a good time to upgrade!
Your participation is what makes us unique; your adoption is what drives us forward.
You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants