Merged
Conversation
Added automatic post create execution of functions and sql statements.
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new SQL DDL elements into the sql_db_utils package while enhancing session management (both asynchronous and synchronous) through post-creation hooks and updating the package version.
- Added multiple new DDLElement classes and corresponding compiler functions in sql_extras.py
- Enhanced session management by introducing postcreate decorators and methods in both asyncio/session_management.py and session_management.py
- Updated the package version from 1.0.1 to 1.1.0
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sql_db_utils/sql_extras.py | New SQL DDL classes and compiler functions for various SQL operations |
| sql_db_utils/asyncio/session_management.py | Adds postcreate functionality to the async session manager and updated type annotations |
| sql_db_utils/session_management.py | Introduces postcreate hooks for the synchronous session manager and updates engine creation logic |
| sql_db_utils/version.py | Version bump from 1.0.1 to 1.1.0 |
Comments suppressed due to low confidence (2)
sql_db_utils/session_management.py:128
- [nitpick] Consider renaming the local variable 'postcreate_auto' in 'postcreate_decorator' to a more generic name (e.g., 'funcs') since the decorator is used for both auto and manual post-create functions.
postcreate_auto = postcreate_store.get(db, [])
sql_db_utils/asyncio/session_management.py:145
- Ensure that 'AsyncEngine' and 'AsyncSession' are properly imported from 'sqlalchemy.ext.asyncio' to avoid runtime errors in asynchronous session management.
session = AsyncSession(bind=engine, future=True, expire_on_commit=False)
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 pull request includes various updates and improvements to the
sql_db_utilspackage, focusing on session management and the addition of new SQL DDL elements. The most important changes include version updates, enhancements to session management, and the introduction of new SQL DDL elements.Version Update:
1.0.1to1.1.0in__version__.py.Session Management Enhancements:
_postcreate_autoand_postcreate_manualtoSQLSessionManagerclasses in bothasyncio/session_management.pyandsession_management.py. These attributes store post-creation functions. [1] [2]postcreate_decorator,register_postcreate,register_postcreate_manual, andrun_postcreatemethods to manage post-creation tasks for databases. [1] [2]_get_enginemethods to execute post-creation tasks after creating default PostgreSQL dependencies. [1] [2]get_sessionmethods to setexpire_on_committoFalse.SQL DDL Elements:
sql_extras.pyto handle various SQL DDL operations, such asCreateExtension,CreateServer,DropServer,CreateUserMapping,DropUserMapping,CreateForeignTable,DropForeignTable,CreatePrefixedIdFunction, andCreateSuffixedIdFunction.Typing Improvements:
CallableandListinsession_management.pyandasyncio/session_management.py. [1] [2]