Skip to content

Feat/auto execute#2

Merged
faizanazim11 merged 2 commits intomainfrom
feat/auto-execute
Mar 16, 2025
Merged

Feat/auto execute#2
faizanazim11 merged 2 commits intomainfrom
feat/auto-execute

Conversation

@faizanazim11
Copy link
Copy Markdown
Contributor

This pull request includes various updates and improvements to the sql_db_utils package, 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:

  • Updated the package version from 1.0.1 to 1.1.0 in __version__.py.

Session Management Enhancements:

  • Added new attributes _postcreate_auto and _postcreate_manual to SQLSessionManager classes in both asyncio/session_management.py and session_management.py. These attributes store post-creation functions. [1] [2]
  • Introduced postcreate_decorator, register_postcreate, register_postcreate_manual, and run_postcreate methods to manage post-creation tasks for databases. [1] [2]
  • Modified _get_engine methods to execute post-creation tasks after creating default PostgreSQL dependencies. [1] [2]
  • Updated get_session methods to set expire_on_commit to False.

SQL DDL Elements:

  • Added new classes and their corresponding compiler functions in sql_extras.py to handle various SQL DDL operations, such as CreateExtension, CreateServer, DropServer, CreateUserMapping, DropUserMapping, CreateForeignTable, DropForeignTable, CreatePrefixedIdFunction, and CreateSuffixedIdFunction.

Typing Improvements:

  • Updated type annotations to include Callable and List in session_management.py and asyncio/session_management.py. [1] [2]

Added automatic post create execution of functions and sql statements.
@faizanazim11 faizanazim11 added the enhancement New feature or request label Mar 16, 2025
@faizanazim11 faizanazim11 requested a review from Copilot March 16, 2025 12:35
@faizanazim11 faizanazim11 self-assigned this Mar 16, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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)

@faizanazim11 faizanazim11 merged commit f552251 into main Mar 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants