示例#1
0
 def __str__(self):
     if self.sort == ASC:
         return str(SqlReference(self.column_name))
     return '{} {}'.format(
         SqlReference(self.column_name),
         self.sort,
     )
示例#2
0
 def __str__(self):
     if self.alias:
         return '{} AS {}'.format(
             SqlReference(self.column_name),
             SqlReference(self.alias),
         )
     return str(SqlReference(self.column_name))
示例#3
0
 def __unicode__(self):
     if self.alias:
         return six.u('%s AS %s') % (
             SqlReference(self.column_name),
             SqlReference(self.alias),
         )
     else:
         return six.text_type(SqlReference(self.column_name))
示例#4
0
 def __unicode__(self):
     if self.sort == ASC:
         return six.text_type(SqlReference(self.column_name))
     else:
         return six.u('%s %s') % (
             SqlReference(self.column_name),
             self.sort,
         )
示例#5
0
 def set(self, *args, **kwds):
     if args and isinstance(args[0], str):
         self._on_conflict = SqlReference(args[0])
         args = args[1:]
     else:
         raise InvalidQueryException(
             'ON CONFLICT (column_name) DO UPDATE needs reference to column as first argument'
         )
     super().set(*args, **kwds)
示例#6
0
    def __unicode__(self):
        if self.alias:
            table = six.u('%s AS %s') % (
                SqlReference(self.table_name),
                SqlReference(self.alias),
            )
        else:
            table = force_text(SqlReference(self.table_name))

        if self._joins:
            self._minimize_joins()
            table += six.u(' ') + six.u(' ').join(
                six.u('%s %s%s') % (
                    JOIN_TYPES[join['type']],
                    join['table'],
                    six.u(' ON %s') %
                    join['ons'] if join['ons'].is_set else '',
                ) for join in self._joins)

        return table
示例#7
0
    def __str__(self):
        if self.alias:
            table = '{} AS {}'.format(
                SqlReference(self.table_name),
                SqlReference(self.alias),
            )
        else:
            table = force_text(SqlReference(self.table_name))

        if self._joins:
            self._minimize_joins()
            table += ' ' + ' '.join(
                '{} {}{}'.format(
                    JOIN_TYPES[join['type']],
                    join['table'],
                    ' ON {}'.format(join['ons']) if join['ons'].is_set else '',
                ) for join in self._joins
            )

        return table
    def __unicode__(self):
        foo = six.u('%(col)s %(rel)s %(val)s')

        value = self.value
        if isinstance(value, (list, tuple, xrange)) and None in value:
            value = [v for v in value if v is not None]
            # If list of values is empty, there must be only condition for NULL.
            if value:
                foo = six.u('(') + foo + six.u(' OR %(col)s IS NULL)')
            else:
                foo = '%(col)s IS NULL'

        return foo % {
            'col': SqlReference(self.column_name),
            'rel': self.relation,
            'val': self._get_value_for_str(value),
        }
示例#9
0
 def _get_expr_as_string(self):
     if isinstance(self.expr, (list, tuple)):
         return six.u(', ').join(force_text(SqlReference(e)) for e in self.expr)
     return SqlReference(self.expr)
示例#10
0
def test_security_subselect():
    select = sqlpuzzle.select_from('table')
    assert str(SqlReference(select)) == '(SELECT * FROM "table")'
示例#11
0
def test_sqlreference_compare_to_str():
    assert SqlReference('foo') == '"foo"'
    assert SqlReference('foo') != 'foo'
示例#12
0
 def __str__(self):
     value_transformer = SqlReference if isinstance(self.value, str) else SqlValue
     return self._value._format_condition(SqlReference(self.column_name), value_transformer=value_transformer)
示例#13
0
 def test_subselect(self):
     select = sqlpuzzle.select_from('table')
     self.assertEqual(str(SqlReference(select)), '(SELECT * FROM "table")')
示例#14
0
 def test_unicode(self):
     self.assertEqual(str(SqlReference(six.u('test'))), '"test"')
示例#15
0
 def test_string(self):
     self.assertEqual(str(SqlReference('test')), '"test"')
示例#16
0
 def test_database_table_column(self):
     self.assertEqual(str(SqlReference('db.table.column')),
                      '"db"."table"."column"')
示例#17
0
 def test_table_column(self):
     self.assertEqual(str(SqlReference('table.column')), '"table"."column"')
示例#18
0
def test_security_table_column():
    assert str(SqlReference('table.column')) == '"table"."column"'
示例#19
0
 def __str__(self):
     return self._value._format_condition(SqlReference(self.column_name),
                                          value_transformer=SqlValue)
示例#20
0
 def __unicode__(self):
     return six.u('%s = %s') % (
         SqlReference(self.column_name),
         SqlValue(self.value),
     )
示例#21
0
 def columns(self):
     return ', '.join(str(SqlReference(value.column_name)) for value in self._parts)
示例#22
0
def test_security_database_table_column():
    assert str(SqlReference('db.table.column')) == '"db"."table"."column"'
示例#23
0
 def __str__(self):
     return '{} = {}'.format(
         SqlReference(self.column_name),
         SqlValue(self.value),
     )
示例#24
0
 def _get_value_for_str(value):
     if isinstance(value, six.string_types):
         return SqlReference(value)
     return SqlValue(value)
示例#25
0
 def columns(self):
     return ', '.join(str(SqlReference(column)) for column in self.all_columns)
示例#26
0
def test_security_string():
    assert str(SqlReference('test')) == '"test"'