def database_column_name(self): """ Column name going into the database - needs to be truncated according to db limitations """ # we have to explicitly truncate the column IDs otherwise postgres will do it # and will choke on them if there are duplicates: http://manage.dimagi.com/default.asp?175495 return truncate_value(self.id)
def database_column_name(self): """ Column name going into the database - needs to be truncated according to db limitations Returns bytes """ # we have to explicitly truncate the column IDs otherwise postgres will do it # and will choke on them if there are duplicates: http://manage.dimagi.com/default.asp?175495 return truncate_value(self.id).encode('utf-8')
def database_column_name(self): """ Column name going into the database - needs to be truncated according to db limitations """ return truncate_value(self.id)
def test_truncate_value_left(self): value = 'string to truncate' truncated = truncate_value(value, max_length=len(value) - 1) self.assertEqual(truncated, 'truncate_849f01fd')
def test_truncate_value_unicode_right(self): value = '\u00e8 string to truncate\u00e8' truncated = truncate_value(value, max_length=len(value) - 1, from_left=False) self.assertEqual(truncated, '\\xe8 string_6be7bea3')
def test_truncate_value_unicode_left(self): value = '\u00e8 string to truncate\u00e8' truncated = truncate_value(value, max_length=len(value) - 1) self.assertEqual(truncated, 'runcate\\xe8_6be7bea3')
def test_truncate_value_right(self): value = 'string to truncate' truncated = truncate_value(value, max_length=len(value) - 1, from_left=False) self.assertEqual(truncated, 'string t_849f01fd')