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