versioned_history example uses deprecated Column.copy() method

266 views
Skip to first unread message

Simon King

unread,
Jun 16, 2021, 7:15:36 AM6/16/21
to sqlal...@googlegroups.com
Hi all,

I'm updating an app from SA 1.3 to 1.4 and getting a SADeprecationWarning:

The Column.copy() method is deprecated and will be removed in a
future release. (deprecated since: 1.4)

The code triggering the warning is based on the versioned_history example:

https://docs.sqlalchemy.org/en/14/_modules/examples/versioned_history/history_meta.html

...and here's the offending function:

def _col_copy(col):
orig = col
col = col.copy()
orig.info["history_copy"] = col
col.unique = False
col.default = col.server_default = None
col.autoincrement = False
return col

For the moment I've switched to calling the private _copy() method
instead, but is there any recommendation of a better approach?

(I did see the issue at
https://github.com/sqlalchemy/sqlalchemy/issues/5953 and understand
why the copy() method was deprecated)

Thanks a lot,

Simon

Mike Bayer

unread,
Jun 16, 2021, 8:26:33 AM6/16/21
to noreply-spamdigest via sqlalchemy
HI Simon -

I believe that example for now should vendor its own "copy()" function that does what's needed.   the function that's there is already un-doing some of the work of the old copy() method in any case.  I think for history table we need column name, datatype, and maybe nullable constraint.

We can accept PRs for this if this is something you would be interested in, although your contributions to the SQLA mailing list are already many :)
-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper


To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.


Simon King

unread,
Jun 17, 2021, 6:06:14 AM6/17/21
to sqlal...@googlegroups.com
Thanks Mike, I'll see what I can do.

Simon
> To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/46661334-a2b9-4548-9003-b487b725615d%40www.fastmail.com.
Reply all
Reply to author
Forward
0 new messages