Exemple #1
0
    def test_columns_indexes_note(self) -> None:
        val = '''
id integer
country varchar [NOT NULL, ref: > countries.country_name]
booking_date date unique pk
note: 'mynote'
indexes {
    (id, country) [pk] // composite primary key
}'''
        res = table_body.parseString(val, parseAll=True)
        self.assertEqual(len(res['columns']), 3)
        self.assertEqual(len(res['indexes']), 1)
        self.assertIsNotNone(res['note'])
        val2 = '''
id integer
country varchar [NOT NULL, ref: > countries.country_name]
booking_date date unique pk
note {
    'mynote'
}
indexes {
    (id, country) [pk] // composite primary key
}'''
        res2 = table_body.parseString(val2, parseAll=True)
        self.assertEqual(len(res2['columns']), 3)
        self.assertEqual(len(res2['indexes']), 1)
        self.assertIsNotNone(res2['note'])
Exemple #2
0
    def test_no_columns(self) -> None:
        val = '''
note: 'mynote'
indexes {
    (id, country) [pk] // composite primary key
}'''
        with self.assertRaises(ParseException):
            table_body.parseString(val, parseAll=True)
Exemple #3
0
    def test_columns_indexes(self):
        val = '''
id integer
country varchar [NOT NULL, ref: > countries.country_name]
booking_date date unique pk
indexes {
    (id, country) [pk] // composite primary key
}'''
        res = table_body.parseString(val, parseAll=True)
        self.assertEqual(len(res['columns']), 3)
        self.assertEqual(len(res['indexes']), 1)
Exemple #4
0
 def test_two_columns(self) -> None:
     val = 'id integer [pk, increment]\nname string\n'
     res = table_body.parseString(val, parseAll=True)
     self.assertEqual(len(res['columns']), 2)
Exemple #5
0
 def test_one_column(self):
     val = 'id integer [pk, increment]\n'
     res = table_body.parseString(val, parseAll=True)
     self.assertEqual(len(res['columns']), 1)