@@ -960,6 +960,10 @@ def get_depending_views(cr, table, column):
960960 return cr .fetchall ()
961961
962962
963+ # sentinel object for function parameters to not alter.
964+ KEEP_CURRENT = object ()
965+
966+
963967class ColumnList (UserList , sql .Composable ):
964968 """
965969 Encapsulate a list of elements that represent column names.
@@ -1025,7 +1029,7 @@ def from_unquoted(cls, cr, list_):
10251029 quoted = [quote_ident (c , cr ._cnx ) for c in list_ ]
10261030 return cls (list_ , quoted )
10271031
1028- def using (self , leading_comma = False , trailing_comma = False , alias = None ):
1032+ def using (self , leading_comma = KEEP_CURRENT , trailing_comma = KEEP_CURRENT , alias = KEEP_CURRENT ):
10291033 """
10301034 Set up parameters to render this list as a string.
10311035
@@ -1036,12 +1040,16 @@ def using(self, leading_comma=False, trailing_comma=False, alias=None):
10361040 :return: a copy of the list with the parameters set
10371041 :rtype: :class:`~odoo.upgrade.util.pg.ColumnList`
10381042 """
1039- if self ._leading_comma is leading_comma and self ._trailing_comma is trailing_comma and self ._alias == alias :
1043+ if (
1044+ (leading_comma is KEEP_CURRENT or self ._leading_comma is leading_comma )
1045+ and (trailing_comma is KEEP_CURRENT or self ._trailing_comma is trailing_comma )
1046+ and (alias is KEEP_CURRENT or self ._alias == alias )
1047+ ):
10401048 return self
10411049 new = ColumnList (self ._unquoted_columns , self .data )
1042- new ._leading_comma = leading_comma
1043- new ._trailing_comma = trailing_comma
1044- new ._alias = alias
1050+ new ._leading_comma = self . _leading_comma if leading_comma is KEEP_CURRENT else bool ( leading_comma )
1051+ new ._trailing_comma = self . _trailing_comma if trailing_comma is KEEP_CURRENT else bool ( trailing_comma )
1052+ new ._alias = self . _alias if alias is KEEP_CURRENT else str ( alias ) if alias is not None else None
10451053 return new
10461054
10471055 def as_string (self , context ):
0 commit comments