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

Several small additions #345

Merged
merged 5 commits into from
Feb 23, 2024
Merged

Several small additions #345

merged 5 commits into from
Feb 23, 2024

Conversation

telser
Copy link
Contributor

@telser telser commented Feb 23, 2024

This adds a handful of small additions. The commits are separated out for each to make viewing, or if needed reverting, the changes in isolation easier.

Most of the changes are limited to the working on the expr level and do not go out beyond that.
A quick overview:

  • 'notExpr' to invert the value of a given 'BooleanExpr'
  • A basic 'VacuumExpr' type and some functionality to support options to a 'VACUUM', such as 'ANALYZE' and 'FULL'.
  • Functionality to allow an 'AlterTableExpr' to be a rename operation. Some care was given to this to not mix it in with the other 'AlterTableExpr' functions as it is, apparently, an alternate form of the 'ALTER TABLE' statement.
  • A 'TruncateTableExpr' that is again basic, but gives access at the expr level to the faster 'TRUNCATE TABLE' (versus 'DELETE').
  • Support for the 'IS DISTINCT FROM' comparison which is treated as a binary "operator" since it is infix in SQL. This has support threaded up to the top level module, because it was so lightweight to do so and is not intrusive on anything else at that level.

Also the 'IS NOT DISTINCT FROM' is added. These let one write queries
that need to work with NULL for whatever reason.  Added the helpers
through the Expr level and up to the field definition.
In addition to the 'TruncateTableExpr' a pair of expr helpers for
creating it are added to allow truncation of one or more tables in a
single statement.

Note that this does not touch the automigration code in any way or add
any higher level functionality. Users can now write the faster
TRUNCATE, but execution and management is entirely up to them.
This is just a small function for the 'AlterTableExpr' that supports
renaming tables. Note this is not supported in the automigration so
all execution and management is left to users.
Includes a handful of functions for options to the VACUUM statement
but does not try to cover everything as this set has been growing in
recent versions of PostgreSQL.

Tests could possibly instead of looking at generated sql, attempt to
inspect the catalog, however, the options influence what is written in
a myriad of ways so the simple approach is taken for the moment.
Copy link
Member

@qxjit qxjit left a comment

Choose a reason for hiding this comment

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

💯 Thanks!

(RawSql.unsafeFromRawSql (RawSql.leftParen <> RawSql.toRawSql left <> RawSql.rightParen))
(RawSql.unsafeFromRawSql (RawSql.leftParen <> RawSql.toRawSql right <> RawSql.rightParen))
(RawSql.unsafeFromRawSql (RawSql.parenthesized left))
(RawSql.unsafeFromRawSql (RawSql.parenthesized right))
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@telser telser merged commit 04c97b5 into master Feb 23, 2024
27 checks passed
@telser telser deleted the telser/small-expr-op-additions branch February 23, 2024 22:15
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.

2 participants