コード例 #1
0
 def _get_column(cls, tables, reverse_tables, name):
     table, _ = tables[None]
     reverse_table, _ = reverse_tables[None]
     if name == 'id':
         return As(table.id * 2, name), As(reverse_table.id * 2 + 1, name)
     elif name == 'from_':
         return table.from_, reverse_table.to.as_(name)
     elif name == 'to':
         return table.to, reverse_table.from_.as_(name)
     elif name == 'type':
         reverse_type, _ = reverse_tables[name][None]
         return table.type, reverse_type.reverse.as_(name)
     else:
         return Column(table, name), Column(reverse_table, name)
コード例 #2
0
ファイル: party.py プロジェクト: nicoe/party_relationship
 def _get_column(cls, tables, reverse_tables, name):
     table, _ = tables[None]
     reverse_table, _ = reverse_tables[None]
     if name == 'id':
         return As(table.id * 2, name), As(reverse_table.id * 2 + 1, name)
     elif name == 'from_':
         # FLA: Fix #11470: Use column in order to be able to use
         # _get_history_table
         return Column(table, 'from_'), reverse_table.to.as_(name)
     elif name == 'to':
         # FLA: Fix #11470: Use column in order to be able to use
         # _get_history_table
         return table.to, Column(reverse_table, 'from_').as_(name)
     elif name == 'type':
         reverse_type, _ = reverse_tables[name][None]
         return table.type, reverse_type.reverse.as_(name)
     else:
         return Column(table, name), Column(reverse_table, name)
コード例 #3
0
ファイル: party.py プロジェクト: shaambhavipathak/nereid
    def __register__(cls, module_name):
        pool = Pool()
        Party = pool.get('party.party')
        ContactMechanism = pool.get('party.contact_mechanism')
        TableHandler = backend.get('TableHandler')
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, module_name)
        party = Party.__table__()
        address = cls.__table__()
        mechanism = ContactMechanism.__table__()

        super(Address, cls).__register__(module_name)

        # Migration from 2.8: move phone and email to contact mechanisms
        for column in ['email', 'phone']:
            if table.column_exist(column):
                join = address.join(
                    party, condition=(party.id == address.party)
                )
                select = join.select(
                    address.create_date, address.create_uid,
                    address.write_date, address.write_uid,
                    As(Literal(column), 'type'),
                    As(Column(address, column), 'value'), address.party,
                    As(Literal(True), 'active'),
                    where=(Column(address, column) != '')
                )
                insert = mechanism.insert(
                    columns=[
                            mechanism.create_date,
                            mechanism.create_uid, mechanism.write_date,
                            mechanism.write_uid, mechanism.type,
                            mechanism.value, mechanism.party, mechanism.active,
                    ], values=select)
                cursor.execute(*insert)

                table.column_rename(column, '%s_deprecated' % column)
コード例 #4
0
 def test_as(self):
     self.assertEqual(str(As(self.column, 'foo')), '"foo"')
コード例 #5
0
ファイル: numeric.py プロジェクト: niezhiyuan1/learngit
 def as_(self, output_name):
     # Use PARSE_COLNAMES instead of CAST for final column
     return As(self.expression, '%s [NUMERIC]' % output_name)