Skip to content

Fix guessing type when it is already presented #80

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions ydb_sqlalchemy/sqlalchemy/compiler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,15 @@ def _is_bound_to_nullable_column(self, bind_name: str) -> bool:
def _guess_bound_variable_type_by_parameters(
self, bind, post_compile_bind_values: list
) -> Optional[sa.types.TypeEngine]:
bind_type = bind.type
if bind.expanding or (isinstance(bind.type, sa.types.NullType) and post_compile_bind_values):
if not isinstance(bind.type, sa.types.NullType):
return bind.type

if post_compile_bind_values:
not_null_values = [v for v in post_compile_bind_values if v is not None]
if not_null_values:
bind_type = _bindparam("", not_null_values[0]).type

if isinstance(bind_type, sa.types.NullType):
return None
return _bindparam("", not_null_values[0]).type

return bind_type
return None

def _get_expanding_bind_names(self, bind_name: str, parameters_values: Mapping[str, List[Any]]) -> List[Any]:
expanding_bind_names = []
Expand Down
Loading