Python sqlalchemy.sql.elements.quoted_name() Examples
The following are 30
code examples of sqlalchemy.sql.elements.quoted_name().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.sql.elements
, or try the search function
.
Example #1
Source File: test_dialect.py From sqlalchemy with MIT License | 6 votes |
def test_quoted_name_bindparam_ok(self): from sqlalchemy.sql.elements import quoted_name with testing.db.connect() as conn: eq_( conn.scalar( select( [ cast( literal(quoted_name("some_name", False)), String, ) ] ) ), "some_name", )
Example #2
Source File: test_cte.py From sqlalchemy with MIT License | 6 votes |
def test_named_alias_disable_quote(self): cte = select([literal(1).label("id")]).cte( name=quoted_name("CTE", quote=False) ) s1 = select([cte.c.id]).alias( name=quoted_name("DontQuote", quote=False) ) s = select([s1]) self.assert_compile( s, "WITH CTE AS (SELECT :param_1 AS id) " "SELECT DontQuote.id FROM " "(SELECT CTE.id AS id FROM CTE) AS DontQuote", )
Example #3
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_apply_map_quoted(self): q1 = _anonymous_label(quoted_name("x%s", True)) q2 = q1.apply_map(("bar")) eq_(q2, "xbar") eq_(q2.quote, True)
Example #4
Source File: base.py From jarvis with GNU General Public License v2.0 | 5 votes |
def normalize_name(self, name): # Remove trailing spaces: FB uses a CHAR() type, # that is padded with spaces name = name and name.rstrip() if name is None: return None elif name.upper() == name and \ not self.identifier_preparer._requires_quotes(name.lower()): return name.lower() elif name.lower() == name: return quoted_name(name, quote=True) else: return name
Example #5
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_name_normalize(self, original, normalized, is_quote): orig_norm = self.dialect.normalize_name(original) eq_(orig_norm, normalized) if is_quote: is_(orig_norm.quote, True) else: assert not isinstance(orig_norm, quoted_name)
Example #6
Source File: elements.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __reduce__(self): return quoted_name, (util.text_type(self), self.quote)
Example #7
Source File: elements.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __add__(self, other): return _anonymous_label( quoted_name( util.text_type.__add__(self, util.text_type(other)), self.quote) )
Example #8
Source File: elements.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __radd__(self, other): return _anonymous_label( quoted_name( util.text_type.__add__(util.text_type(other), self), self.quote) )
Example #9
Source File: base.py From android_universal with MIT License | 5 votes |
def normalize_name(self, name): # Remove trailing spaces: FB uses a CHAR() type, # that is padded with spaces name = name and name.rstrip() if name is None: return None elif name.upper() == name and \ not self.identifier_preparer._requires_quotes(name.lower()): return name.lower() elif name.lower() == name: return quoted_name(name, quote=True) else: return name
Example #10
Source File: base.py From android_universal with MIT License | 5 votes |
def normalize_name(self, name): if name is None: return None if util.py2k: if isinstance(name, str): name = name.decode(self.encoding) if name.upper() == name and not \ self.identifier_preparer._requires_quotes(name.lower()): return name.lower() elif name.lower() == name: return quoted_name(name, quote=True) else: return name
Example #11
Source File: test_reflection.py From android_universal with MIT License | 5 votes |
def define_tables(cls, metadata): Table( quoted_name('t1', quote=True), metadata, Column('id', Integer, primary_key=True), ) Table( quoted_name('t2', quote=True), metadata, Column('id', Integer, primary_key=True), Column('t1id', ForeignKey('t1.id')) )
Example #12
Source File: test_reflection.py From android_universal with MIT License | 5 votes |
def test_reflect_lowercase_forced_tables(self): m2 = MetaData(testing.db) t2_ref = Table(quoted_name('t2', quote=True), m2, autoload=True) t1_ref = m2.tables['t1'] assert t2_ref.c.t1id.references(t1_ref.c.id) m3 = MetaData(testing.db) m3.reflect(only=lambda name, m: name.lower() in ('t1', 't2')) assert m3.tables['t2'].c.t1id.references(m3.tables['t1'].c.id)
Example #13
Source File: base.py From android_universal with MIT License | 5 votes |
def quote_dotted(name, quote): """quote the elements of a dotted name""" if util.sqla_09 and isinstance(name, quoted_name): return quote(name) result = '.'.join([quote(x) for x in name.split('.')]) return result
Example #14
Source File: elements.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __new__(cls, value, quote): if value is None: return None # experimental - don't bother with quoted_name # if quote flag is None. doesn't seem to make any dent # in performance however # elif not sprcls and quote is None: # return value elif isinstance(value, cls) and ( quote is None or value.quote == quote ): return value self = super(quoted_name, cls).__new__(cls, value) self.quote = quote return self
Example #15
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_pickle_anon_label(self): q1 = _anonymous_label(quoted_name("x", True)) for loads, dumps in picklers(): q2 = loads(dumps(q1)) assert isinstance(q2, _anonymous_label) eq_(str(q1), str(q2)) eq_(q1.quote, q2.quote)
Example #16
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_pickle_quote(self): q1 = quoted_name("x", True) for loads, dumps in picklers(): q2 = loads(dumps(q1)) eq_(str(q1), str(q2)) eq_(q1.quote, q2.quote)
Example #17
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_repr_unicode(self): name = quoted_name(u"姓名", None) if util.py2k: eq_(repr(name), "'\u59d3\u540d'") else: eq_(repr(name), repr(u"姓名"))
Example #18
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def _assert_quoted(self, value, quote): assert isinstance(value, quoted_name) eq_(value.quote, quote)
Example #19
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_coerce_none(self): q1 = quoted_name(None, False) eq_(q1, None)
Example #20
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_coerce_quoted_retain(self): q1 = quoted_name("x", False) q2 = quoted_name(q1, False) eq_(q2.quote, False)
Example #21
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_coerce_quoted_none(self): q1 = quoted_name("x", False) q2 = quoted_name(q1, None) eq_(q2.quote, False)
Example #22
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_coerce_quoted_switch(self): q1 = quoted_name("x", False) q2 = quoted_name(q1, True) eq_(q2.quote, True)
Example #23
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_concat_anon(self): q1 = _anonymous_label(quoted_name("x", True)) assert isinstance(q1, _anonymous_label) value = q1 + "y" assert isinstance(value, _anonymous_label) self._assert_quoted(value, True)
Example #24
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_rconcat_quotenone(self): q1 = quoted_name("x", None) self._assert_not_quoted("y" + q1)
Example #25
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_rconcat_quotefalse(self): q1 = quoted_name("x", False) self._assert_not_quoted("y" + q1)
Example #26
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_rconcat_quotetrue(self): q1 = quoted_name("x", True) self._assert_not_quoted("y" + q1)
Example #27
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_concat_quotenone(self): q1 = quoted_name("x", None) self._assert_not_quoted("y" + q1)
Example #28
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_concat_quotetrue(self): q1 = quoted_name("x", True) self._assert_not_quoted("y" + q1)
Example #29
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_literal_column_label_alias_diffname_explcit_quote(self): col = sql.literal_column("NEEDS QUOTES").label( quoted_name("NEEDS QUOTES_", True) ) self.assert_compile( select([col]).alias().select(), 'SELECT anon_1."NEEDS QUOTES_" FROM ' '(SELECT NEEDS QUOTES AS "NEEDS QUOTES_") AS anon_1', )
Example #30
Source File: test_quote.py From sqlalchemy with MIT License | 5 votes |
def test_literal_column_label_alias_samename_explcit_quote(self): col = sql.literal_column("NEEDS QUOTES").label( quoted_name("NEEDS QUOTES", True) ) self.assert_compile( select([col]).alias().select(), 'SELECT anon_1."NEEDS QUOTES" FROM ' '(SELECT NEEDS QUOTES AS "NEEDS QUOTES") AS anon_1', )