Ejemplo n.º 1
0
 def __unicode__(self):
     into_outfile = six.u('INTO OUTFILE %s') % SqlValue(self._into_outfile)
     if self._fields_terminated_by is not None:
         into_outfile += six.u(' FIELDS TERMINATED BY %s') % SqlValue(
             self._fields_terminated_by)
     if self._lines_terminated_by is not None:
         into_outfile += six.u(' LINES TERMINATED BY %s') % SqlValue(
             self._lines_terminated_by)
     if self._optionally_enclosed_by is not None:
         into_outfile += six.u(' OPTIONALLY ENCLOSED BY %s') % SqlValue(
             self._optionally_enclosed_by)
     return into_outfile
Ejemplo n.º 2
0
 def __str__(self):
     into_outfile = 'INTO OUTFILE {}'.format(SqlValue(self._into_outfile))
     if self._fields_terminated_by is not None:
         into_outfile += ' FIELDS TERMINATED BY {}'.format(
             SqlValue(self._fields_terminated_by))
     if self._lines_terminated_by is not None:
         into_outfile += ' LINES TERMINATED BY {}'.format(
             SqlValue(self._lines_terminated_by))
     if self._optionally_enclosed_by is not None:
         into_outfile += ' OPTIONALLY ENCLOSED BY {}'.format(
             SqlValue(self._optionally_enclosed_by))
     return into_outfile
Ejemplo n.º 3
0
 def __str__(self):
     return '{} = {}'.format(
         SqlReference(self.column_name),
         SqlValue(self.value),
     )
Ejemplo n.º 4
0
 def _get_value_for_str(value):
     return SqlValue(value)
Ejemplo n.º 5
0
 def _get_value_for_str(value):
     if isinstance(value, six.string_types):
         return SqlReference(value)
     return SqlValue(value)
Ejemplo n.º 6
0
 def test_none(self):
     self.assertEqual(str(SqlValue(None)), 'NULL')
Ejemplo n.º 7
0
 def test_generator(self):
     self.assertEqual(str(SqlValue(x for x in (12, 23, 34))),
                      '(12, 23, 34)')
Ejemplo n.º 8
0
 def test_frozen_set(self):
     self.assertEqual(str(SqlValue(frozenset([12, 23]))), '(12, 23)')
Ejemplo n.º 9
0
 def test_float(self):
     self.assertEqual(str(SqlValue(23.456)), '23.45600')
Ejemplo n.º 10
0
 def test_long_integer(self):
     self.assertEqual(str(SqlValue(123456789012345)), '123456789012345')
Ejemplo n.º 11
0
 def test_integer(self):
     self.assertEqual(str(SqlValue(42)), '42')
Ejemplo n.º 12
0
 def test_unicode(self):
     self.assertEqual(str(SqlValue(six.u('Hello World!'))),
                      '\'Hello World!\'')
Ejemplo n.º 13
0
    def test_new_line(self):
        value = """first line
second line"""
        self.assertEqual(str(SqlValue(value)), "'first line\\nsecond line'")
Ejemplo n.º 14
0
 def test_string(self):
     self.assertEqual(str(SqlValue('Hello World!')), '\'Hello World!\'')
Ejemplo n.º 15
0
 def test_slash(self):
     self.assertEqual(str(SqlValue('test\\test')), "'test\\\\test'")
Ejemplo n.º 16
0
 def test_tuple_with_integer(self):
     self.assertEqual(str(SqlValue((12, 23, 34))), '(12, 23, 34)')
Ejemplo n.º 17
0
 def test_empty_tuple(self):
     self.assertRaises(sqlpuzzle.exceptions.InvalidArgumentException, str,
                       SqlValue(()))
Ejemplo n.º 18
0
 def test_decimal(self):
     self.assertEqual(str(SqlValue(decimal.Decimal('23.456'))), '23.45600')
Ejemplo n.º 19
0
 def test_empty_frozen_set(self):
     self.assertRaises(sqlpuzzle.exceptions.InvalidArgumentException, str,
                       SqlValue(frozenset()))
Ejemplo n.º 20
0
 def test_boolean(self):
     self.assertEqual(str(SqlValue(True)), '1')
Ejemplo n.º 21
0
 def test_xrange(self):
     self.assertEqual(str(SqlValue(xrange(5))), '(0, 1, 2, 3, 4)')
Ejemplo n.º 22
0
 def test_date(self):
     self.assertEqual(str(SqlValue(datetime.date(2011, 5, 25))),
                      '\'2011-05-25\'')
Ejemplo n.º 23
0
 def test_subselect(self):
     select = sqlpuzzle.select_from('table')
     self.assertEqual(str(SqlValue(select)), '(SELECT * FROM "table")')
Ejemplo n.º 24
0
 def test_datetime(self):
     self.assertEqual(
         str(SqlValue(datetime.datetime(2011, 5, 25, 19, 33, 20))),
         '\'2011-05-25T19:33:20\'')
Ejemplo n.º 25
0
 def _str_separator(self):
     if self._separator:
         return six.u(' SEPARATOR %s') % SqlValue(self._separator)
     return ''
Ejemplo n.º 26
0
 def test_list_with_string(self):
     self.assertEqual(str(SqlValue(['a', 'b', 'c'])), "('a', 'b', 'c')")
Ejemplo n.º 27
0
 def __unicode__(self):
     return six.u('%s = %s') % (
         SqlReference(self.column_name),
         SqlValue(self.value),
     )
Ejemplo n.º 28
0
 def test_list_with_integer(self):
     self.assertEqual(str(SqlValue([12, 23, 34])), '(12, 23, 34)')
Ejemplo n.º 29
0
 def values(self, column_order=None):
     values = self._parts
     if column_order:
         map_of_col_to_val = dict((value.column_name, value) for value in values)
         values = [map_of_col_to_val.get(column, None) for column in column_order]
     return ', '.join(str(SqlValue(value.value if value else None)) for value in values)
Ejemplo n.º 30
0
 def test_tuple_with_string(self):
     self.assertEqual(str(SqlValue(('a', 'b', 'c'))), "('a', 'b', 'c')")