Conversation
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds PostgreSQL syntax validation to the pqb integration test suite so that snapshot-tested SQL is parsed/validated (closing the gap described in #10: “Validate syntax of generated SQL”).
Changes:
- Introduce a
ValidateSQLhelper trait inpqb/tests/common.rsthat parses SQL withpg_query. - Update most SQL snapshot assertions across test modules to call
.validate()on the generated SQL. - Add
pg_queryas adev-dependency(and updateCargo.lockaccordingly).
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
pqb/tests/common.rs |
Adds ValidateSQL helper that parses SQL via pg_query. |
pqb/tests/select.rs |
Applies .validate() to generated SELECT SQL snapshots (and a couple of statement snapshots). |
pqb/tests/insert.rs |
Applies .validate() to INSERT snapshots; leaves one known-invalid ON CONFLICT case unvalidated with a FIXME. |
pqb/tests/create_table.rs |
Applies .validate() to CREATE TABLE snapshots; leaves generated-column case unvalidated due to dialect/version mismatch. |
pqb/tests/index.rs |
Applies .validate() to CREATE INDEX snapshots. |
pqb/tests/drop.rs |
Applies .validate() to DROP statements. |
pqb/tests/explain.rs |
Applies .validate() to EXPLAIN statements. |
pqb/tests/expr.rs |
Applies .validate() to expression-driven SELECT snapshots. |
pqb/tests/types.rs |
Applies .validate() to identifier/qualified name rendering snapshots. |
pqb/Cargo.toml |
Adds pg_query = 6.1.1 under dev-dependencies. |
Cargo.lock |
Locks the new dependency graph introduced by pg_query. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tisonkun
commented
Feb 8, 2026
| .generated_as_virtual(Expr::column("sum").div(Expr::value(2))), | ||
| ) | ||
| .to_sql(), | ||
| // .validate(), // TODO: Before PostgreSQL 18, STORED is the only supported kind and must be specified. |
Signed-off-by: tison <wander4096@gmail.com>
tisonkun
commented
Feb 8, 2026
| /// SQL value variants. | ||
| #[derive(Debug, Clone, PartialEq)] | ||
| #[expect(missing_docs)] | ||
| #[allow(missing_docs)] |
Collaborator
Author
There was a problem hiding this comment.
Clippy false positive - https://github.com/rust-lang/rust-clippy/issues/16534
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This closes rust-lang/rust-clippy#10