@@ -960,6 +960,10 @@ def get_depending_views(cr, table, column):
960
960
return cr .fetchall ()
961
961
962
962
963
+ # sentinel object for function parameters to not alter.
964
+ KEEP_CURRENT = object ()
965
+
966
+
963
967
class ColumnList (UserList , sql .Composable ):
964
968
"""
965
969
Encapsulate a list of elements that represent column names.
@@ -1025,7 +1029,7 @@ def from_unquoted(cls, cr, list_):
1025
1029
quoted = [quote_ident (c , cr ._cnx ) for c in list_ ]
1026
1030
return cls (list_ , quoted )
1027
1031
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 ):
1029
1033
"""
1030
1034
Set up parameters to render this list as a string.
1031
1035
@@ -1036,12 +1040,16 @@ def using(self, leading_comma=False, trailing_comma=False, alias=None):
1036
1040
:return: a copy of the list with the parameters set
1037
1041
:rtype: :class:`~odoo.upgrade.util.pg.ColumnList`
1038
1042
"""
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
+ ):
1040
1048
return self
1041
1049
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
1045
1053
return new
1046
1054
1047
1055
def as_string (self , context ):
0 commit comments