-
Notifications
You must be signed in to change notification settings - Fork 143
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
Web2py filesystem issues #697
Conversation
Binary field type in PostgreSQL is type "BYTEA" not BLOB.
The filename is being inadvertently encoded which results in each subsequent lookup being unable to locate the appropriate path and results in a web2py_filesystem duplicate primary key error when starting py4web.
@@ -488,7 +488,8 @@ def try_create_web2py_filesystem(db): | |||
raise NotImplementedError( | |||
"DatabaseStoredFile only supported by mysql, potresql, sqlite" | |||
) | |||
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content BLOB, PRIMARY KEY(path));" | |||
blobType = "BYTEA" if db._adapter.dbengine == "postgres" else "BLOB" | |||
sql = "CREATE TABLE IF NOT EXISTS web2py_filesystem (path VARCHAR(255), content %(blobType)s, PRIMARY KEY(path));" % {"blobType": blobType} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is problematic. It will may break apps of current users if the table already exists. Can you explain why it is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "BLOB" field type doesn't exist in PostgreSQL, it's type "BYTEA", so currently it just errors attempting to create the web2py_filesystem table with "BLOB type does not exist" since it's not available in PostgreSQL.
https://www.postgresql.org/docs/current/datatype-binary.html
@@ -315,7 +315,11 @@ def create_table(self, table, migrate=True, fake_migrate=False, polymodel=None): | |||
query = "CREATE TABLE %s(\n %s\n)%s" % (table_rname, fields, other) | |||
|
|||
uri = self.adapter.uri | |||
if uri.startswith("sqlite:///") or uri.startswith("spatialite:///"): | |||
if isinstance(self, InDBMigrator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
Logic to resolve #696.