Skip to content

Commit

Permalink
add extend_existing
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Oct 17, 2022
1 parent ef274aa commit 7e9a982
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ckanext/datarequests/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def get_open_datarequests_number(cls):
sa.Column('close_circumstance', sa.types.Unicode(constants.CLOSE_CIRCUMSTANCE_MAX_LENGTH), primary_key=False, default=u'')
if closing_circumstances_enabled else None,
sa.Column('approx_publishing_date', sa.types.DateTime, primary_key=False, default=None)
if closing_circumstances_enabled else None
if closing_circumstances_enabled else None,
extend_existing = True,
)

# Create the table only if it does not exist
Expand Down Expand Up @@ -146,7 +147,8 @@ def get_comment_datarequests_number(cls, **kw):
sa.Column('user_id', sa.types.UnicodeText, primary_key=False, default=u''),
sa.Column('datarequest_id', sa.types.UnicodeText, primary_key=True, default=uuid4),
sa.Column('time', sa.types.DateTime, primary_key=True, default=u''),
sa.Column('comment', sa.types.Unicode(constants.COMMENT_MAX_LENGTH), primary_key=False, default=u'')
sa.Column('comment', sa.types.Unicode(constants.COMMENT_MAX_LENGTH), primary_key=False, default=u''),
extend_existing = True
)

# Create the table only if it does not exist
Expand Down Expand Up @@ -177,7 +179,8 @@ def get_datarequest_followers_number(cls, **kw):
sa.Column('id', sa.types.UnicodeText, primary_key=True, default=uuid4),
sa.Column('user_id', sa.types.UnicodeText, primary_key=False, default=u''),
sa.Column('datarequest_id', sa.types.UnicodeText, primary_key=True, default=uuid4),
sa.Column('time', sa.types.DateTime, primary_key=True, default=u'')
sa.Column('time', sa.types.DateTime, primary_key=True, default=u''),
extend_existing = True
)

# Create the table only if it does not exist
Expand Down

2 comments on commit 7e9a982

@RossWebsterWork
Copy link

Choose a reason for hiding this comment

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

Hi @mutantsan

I am doing a delta against qld-gov-au and noticed that this commit is on against our version. Is this change required?
master...DataShades:ckanext-datarequests:dev

Regards,

@RossWebsterWork

@mutantsan
Copy link
Author

Choose a reason for hiding this comment

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

As I remember, during tests I had an error like Table '' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object. So those lines have fixed the issue.

Please sign in to comment.