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), )
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)
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)
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)
def test_quote_none(): assert "null" == quote(None)
def test_quote_backslash(): assert r"'c:\\\\whee'" == quote(r"c:\\whee")
def test_quote_apostrophe(): assert "'it''s'" == quote("it's")
def test_quote(): assert "'foo'" == quote("foo")
def test_quote_none(): assert "null" == quote( None )
def test_quote_backslash(): assert r"'c:\\\\whee'" == quote( r"c:\\whee" )
def test_quote_apostrophe(): assert "'it''s'" == quote( "it's" )
def test_quote(): assert "'foo'" == quote( "foo" )
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 ) )