コード例 #1
0
ファイル: Stub_object.py プロジェクト: vijo/luminotes
 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),
     )
コード例 #2
0
ファイル: Stub_object.py プロジェクト: LimpingNinja/luminotes
    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)
コード例 #3
0
ファイル: Stub_object.py プロジェクト: vijo/luminotes
    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)
コード例 #4
0
ファイル: Stub_object.py プロジェクト: vijo/luminotes
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)
コード例 #5
0
ファイル: Stub_object.py プロジェクト: LimpingNinja/luminotes
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)
コード例 #6
0
def test_quote_none():
    assert "null" == quote(None)
コード例 #7
0
def test_quote_backslash():
    assert r"'c:\\\\whee'" == quote(r"c:\\whee")
コード例 #8
0
def test_quote_apostrophe():
    assert "'it''s'" == quote("it's")
コード例 #9
0
def test_quote():
    assert "'foo'" == quote("foo")
コード例 #10
0
ファイル: Test_persistent.py プロジェクト: osborne6/luminotes
def test_quote_none():
  assert "null" == quote( None )
コード例 #11
0
ファイル: Test_persistent.py プロジェクト: osborne6/luminotes
def test_quote_backslash():
  assert r"'c:\\\\whee'" == quote( r"c:\\whee" )
コード例 #12
0
ファイル: Test_persistent.py プロジェクト: osborne6/luminotes
def test_quote_apostrophe():
  assert "'it''s'" == quote( "it's" )
コード例 #13
0
ファイル: Test_persistent.py プロジェクト: osborne6/luminotes
def test_quote():
  assert "'foo'" == quote( "foo" )
コード例 #14
0
ファイル: Stub_object.py プロジェクト: LimpingNinja/luminotes
 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 ) )