File: test_column.py

package info (click to toggle)
python-sql 1.4.0-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 436 kB
  • sloc: python: 3,956; sh: 9; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This file is part of python-sql.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest

from sql import AliasManager, Column, Table


class TestColumn(unittest.TestCase):
    def test_column(self):
        column = Column(Table('t'), 'c')
        self.assertEqual(str(column), '"c"')
        self.assertEqual(column.name, 'c')
        self.assertEqual(column.column_name, '"c"')

        with AliasManager():
            self.assertEqual(str(column), '"a"."c"')

    def test_quote_in_column(self):
        column = Column(Table('t'), 'b "c"')
        self.assertEqual(str(column), '"b ""c"""')
        self.assertEqual(column.name, 'b "c"')
        self.assertEqual(column.column_name, '"b ""c"""')

        with AliasManager():
            self.assertEqual(str(column), '"a"."b ""c"""')