コード例 #1
0
 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)
コード例 #2
0
ファイル: __init__.py プロジェクト: dimagi/commcare-hq
 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')
コード例 #3
0
 def database_column_name(self):
     """
     Column name going into the database - needs to be truncated according to db limitations
     """
     return truncate_value(self.id)
コード例 #4
0
ファイル: test_utils.py プロジェクト: kkrampa/commcare-hq
 def test_truncate_value_left(self):
     value = 'string to truncate'
     truncated = truncate_value(value, max_length=len(value) - 1)
     self.assertEqual(truncated, 'truncate_849f01fd')
コード例 #5
0
ファイル: test_utils.py プロジェクト: kkrampa/commcare-hq
 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')
コード例 #6
0
ファイル: test_utils.py プロジェクト: kkrampa/commcare-hq
 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')
コード例 #7
0
ファイル: test_utils.py プロジェクト: kkrampa/commcare-hq
 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')
コード例 #8
0
 def test_truncate_value_left(self):
     value = 'string to truncate'
     truncated = truncate_value(value, max_length=len(value) - 1)
     self.assertEqual(truncated, 'truncate_849f01fd')
コード例 #9
0
 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')
コード例 #10
0
 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')
コード例 #11
0
 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')
コード例 #12
0
 def database_column_name(self):
     """
     Column name going into the database - needs to be truncated according to db limitations
     """
     return truncate_value(self.id)