Skip to content

Changes to support MSSQL #33

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 6 commits into
base: master
Choose a base branch
from
Open

Changes to support MSSQL #33

wants to merge 6 commits into from

Conversation

ifMatt
Copy link

@ifMatt ifMatt commented Feb 6, 2025

Added MsSQL database entry and included test coverage that matches current pattern for other supported databases.

Copy link
Owner

@erezsh erezsh left a comment

Choose a reason for hiding this comment

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

Looks like a good start.

return table("information_schema", "tables")

def list_tables(self, table_schema: str, like: Compilable = None) -> Select:
if table_schema == None:
Copy link
Owner

Choose a reason for hiding this comment

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

You can make this a lot shorter by using table_schema or SKIP

Copy link
Author

Choose a reason for hiding this comment

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

Yep, good catch. I have implemented a change.

# Subtracting 2 due to wierd precision issues in PostgreSQL
return super()._convert_db_precision_to_digits(p) - 2

def set_timezone_to_utc(self) -> str:
Copy link
Owner

Choose a reason for hiding this comment

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

Is it always UTC? If so, worth documenting.

Copy link
Author

Choose a reason for hiding this comment

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

It is, I have added code commentary. Is there an additional location that this should be documented?

bool: "BIT",
datetime: "datetime2",
}[t]
except:
Copy link
Owner

Choose a reason for hiding this comment

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

catch KeyError

Copy link
Author

Choose a reason for hiding this comment

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

I have implemented a change

Copy link
Owner

@erezsh erezsh left a comment

Choose a reason for hiding this comment

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

Overall looks good!

Left a few small comments.

return super()._query_cursor(c, sql_code)
except self.mssql.DatabaseError as e:
raise QueryError(e)
except e:
Copy link
Owner

Choose a reason for hiding this comment

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

This is unnecessary, and actually will hide the real type of the exception.

Copy link
Author

Choose a reason for hiding this comment

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

I think I added this originally to match the oracle module. I have now removed this.

return f"datetimeoffset"
try:
return {
str: "VARCHAR(1024)",
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, I'm not well-versed in mssql. Is it a good idea to specify 1024? Is that the maximum size?

Copy link
Author

Choose a reason for hiding this comment

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

I have have changed this to used NVARCHAR(MAX) to better align with other database modules. I also noticed an issue relating to foreign keys that I have now remedied.

pyproject.toml Outdated
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sqeleton"
version = "0.1.7"
version = "0.1.8"
Copy link
Owner

Choose a reason for hiding this comment

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

Please don't change the version. I will do it later when I make a release.

(maybe you changed it for testing and forgot to remove?)

Copy link
Author

Choose a reason for hiding this comment

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

Yes, sorry I was testing the difference between the versions. I have now reverted this.

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