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
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
def __str__(self): return '{} = {}'.format( SqlReference(self.column_name), SqlValue(self.value), )
def _get_value_for_str(value): return SqlValue(value)
def _get_value_for_str(value): if isinstance(value, six.string_types): return SqlReference(value) return SqlValue(value)
def test_none(self): self.assertEqual(str(SqlValue(None)), 'NULL')
def test_generator(self): self.assertEqual(str(SqlValue(x for x in (12, 23, 34))), '(12, 23, 34)')
def test_frozen_set(self): self.assertEqual(str(SqlValue(frozenset([12, 23]))), '(12, 23)')
def test_float(self): self.assertEqual(str(SqlValue(23.456)), '23.45600')
def test_long_integer(self): self.assertEqual(str(SqlValue(123456789012345)), '123456789012345')
def test_integer(self): self.assertEqual(str(SqlValue(42)), '42')
def test_unicode(self): self.assertEqual(str(SqlValue(six.u('Hello World!'))), '\'Hello World!\'')
def test_new_line(self): value = """first line second line""" self.assertEqual(str(SqlValue(value)), "'first line\\nsecond line'")
def test_string(self): self.assertEqual(str(SqlValue('Hello World!')), '\'Hello World!\'')
def test_slash(self): self.assertEqual(str(SqlValue('test\\test')), "'test\\\\test'")
def test_tuple_with_integer(self): self.assertEqual(str(SqlValue((12, 23, 34))), '(12, 23, 34)')
def test_empty_tuple(self): self.assertRaises(sqlpuzzle.exceptions.InvalidArgumentException, str, SqlValue(()))
def test_decimal(self): self.assertEqual(str(SqlValue(decimal.Decimal('23.456'))), '23.45600')
def test_empty_frozen_set(self): self.assertRaises(sqlpuzzle.exceptions.InvalidArgumentException, str, SqlValue(frozenset()))
def test_boolean(self): self.assertEqual(str(SqlValue(True)), '1')
def test_xrange(self): self.assertEqual(str(SqlValue(xrange(5))), '(0, 1, 2, 3, 4)')
def test_date(self): self.assertEqual(str(SqlValue(datetime.date(2011, 5, 25))), '\'2011-05-25\'')
def test_subselect(self): select = sqlpuzzle.select_from('table') self.assertEqual(str(SqlValue(select)), '(SELECT * FROM "table")')
def test_datetime(self): self.assertEqual( str(SqlValue(datetime.datetime(2011, 5, 25, 19, 33, 20))), '\'2011-05-25T19:33:20\'')
def _str_separator(self): if self._separator: return six.u(' SEPARATOR %s') % SqlValue(self._separator) return ''
def test_list_with_string(self): self.assertEqual(str(SqlValue(['a', 'b', 'c'])), "('a', 'b', 'c')")
def __unicode__(self): return six.u('%s = %s') % ( SqlReference(self.column_name), SqlValue(self.value), )
def test_list_with_integer(self): self.assertEqual(str(SqlValue([12, 23, 34])), '(12, 23, 34)')
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)
def test_tuple_with_string(self): self.assertEqual(str(SqlValue(('a', 'b', 'c'))), "('a', 'b', 'c')")