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

Add preliminary Ingres/Vector/Actian Avalanche support #36

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 9 additions & 2 deletions agatesql/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,26 @@ def make_sql_table(table, table_name, dialect=None, db_schema=None, constraints=
sql_column_kwargs = {}

if constraints:
if isinstance(column.data_type, agate.Text) and dialect == 'mysql':
if isinstance(column.data_type, agate.Text) and dialect in ('ingres', 'mysql'):
length = table.aggregate(agate.MaxLength(column_name)) * decimal.Decimal(col_len_multiplier)
if length > 21844:
# @see https://dev.mysql.com/doc/refman/5.7/en/string-type-overview.html
sql_column_type = TEXT
elif dialect == 'ingres' and length > 16000:
# @see https://docs.actian.com/actianx/11.2/index.html#page/SQLRef%2FCharacter_Data_Types.htm%23
# Could be longer but ~16K is a reasonable cut off to switch to CLOB
Comment on lines +202 to +204
Copy link
Member

Choose a reason for hiding this comment

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

The preceding condition is "length > 21844" (which is 65,535 bytes divided by 3). The Actian docs mention 32,000 bytes, so not sure how you chose 16,000. I'll go with 10,666 (32,000 divided by 3) https://docs.actian.com/ingres/11.2/index.html#page/SQLRef/Character_Data_Types.htm

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, ~10K is a better safe/sane default. It was a while ago so like you, I cannot figure out how I chose ~16K either 😜

Thanks for taking the time to review and improve the original idea! Happy New Year 🎉

sql_column_type = TEXT
else:
# If length is zero, SQLAlchemy may raise "VARCHAR requires a length on dialect mysql".
# For Ingres, default length is 1
sql_type_kwargs['length'] = length if length >= min_col_len else min_col_len

# PostgreSQL and SQLite don't have scale default 0.
# @see https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
# @see https://www.sqlite.org/datatype3.html
if isinstance(column.data_type, agate.Number) and dialect in ('mssql', 'mysql', 'oracle'):
if isinstance(column.data_type, agate.Number) and dialect in ('ingres', 'mssql', 'mysql', 'oracle'):
# Ingres/Vector/Avalanche has precision range 1-39 and default 5, scale default 0.
# @see https://docs.actian.com/actianx/11.2/SQLRef/Numeric_Data_Types.htm#ww109458
# MySQL has precision range 1-65 and default 10, scale default 0.
# @see https://dev.mysql.com/doc/refman/5.7/en/fixed-point-types.html
# Oracle has precision range 1-38 and default 38, scale default 0.
Expand Down