Ejemplo n.º 1
0
 def sql_create(self):
     return "insert into stub_object ( id, revision, value, value2 ) " + "values ( %s, %s, %s, %s );" % (
         quote(self.object_id),
         notz_quote(self.revision),
         quote(self.__value),
         quote(self.__value2),
     )
Ejemplo n.º 2
0
    def sql_id_exists(object_id, revision=None):
        if revision:
            return "select id from stub_object where id = %s and revision = %s;" % (
                quote(object_id), notz_quote(revision))

        return "select id from stub_object where id = %s order by revision desc limit 1;" % quote(
            object_id)
Ejemplo n.º 3
0
    def sql_id_exists(object_id, revision=None):
        if revision:
            return "select id from stub_object where id = %s and revision = %s;" % (
                quote(object_id),
                notz_quote(revision),
            )

        return "select id from stub_object where id = %s order by revision desc limit 1;" % quote(object_id)
Ejemplo n.º 4
0
def notz_quote(value):
    """
  Apparently, pysqlite2 chokes on timestamps that have a timezone when reading them out of the
  database, so for purposes of the unit tests, strip off the timezone on all datetime objects.
  """
    if isinstance(value, datetime):
        value = value.replace(tzinfo=None)

    return quote(value)
Ejemplo n.º 5
0
def notz_quote(value):
    """
  Apparently, pysqlite2 chokes on timestamps that have a timezone when reading them out of the
  database, so for purposes of the unit tests, strip off the timezone on all datetime objects.
  """
    if isinstance(value, datetime):
        value = value.replace(tzinfo=None)

    return quote(value)
Ejemplo n.º 6
0
def test_quote_none():
    assert "null" == quote(None)
Ejemplo n.º 7
0
def test_quote_backslash():
    assert r"'c:\\\\whee'" == quote(r"c:\\whee")
Ejemplo n.º 8
0
def test_quote_apostrophe():
    assert "'it''s'" == quote("it's")
Ejemplo n.º 9
0
def test_quote():
    assert "'foo'" == quote("foo")
Ejemplo n.º 10
0
def test_quote_none():
  assert "null" == quote( None )
Ejemplo n.º 11
0
def test_quote_backslash():
  assert r"'c:\\\\whee'" == quote( r"c:\\whee" )
Ejemplo n.º 12
0
def test_quote_apostrophe():
  assert "'it''s'" == quote( "it's" )
Ejemplo n.º 13
0
def test_quote():
  assert "'foo'" == quote( "foo" )
Ejemplo n.º 14
0
 def sql_create(self):
     return \
       "insert into stub_object ( id, revision, value, value2 ) " + \
       "values ( %s, %s, %s, %s );" % \
       ( quote( self.object_id ), notz_quote( self.revision ), quote( self.__value ),
         quote( self.__value2 ) )