from sqlobject import *
from sqlobject.tests.dbtest import *

########################################
## Schema per connection
########################################

class Test(SQLObject):
    foo = UnicodeCol(length=200)

def test_connection_schema():
    if not supports('schema'):
        return
    conn = getConnection(schema=None)
    conn.schema = None
    conn.query('CREATE SCHEMA test')
    setupClass(Test)
    Test(foo='bar')
    conn = Test._connection
    assert conn.schema, \
        """To test a schema you need to give a connection uri that contains a schema."""
    assert conn.queryAll("select * from %s.test" % conn.schema)

from sqlobject import *
from sqlobject.tests.dbtest import *

########################################
## Schema per connection
########################################

class Test(SQLObject):
    foo = UnicodeCol(length=200)

def test_connection_schema():
    if not supports('schema'):
        return
    conn = getConnection()
    conn.schema = None
    conn.query('CREATE SCHEMA test')
    conn.schema = 'test'
    conn.query('SET search_path TO test')
    setupClass(Test)
    Test(foo='bar')
    assert conn.queryAll("SELECT * FROM test.test")

Allow the test to be run without 'schema=' parameter in the DB URI.
Allow the test to be run without 'schema=' parameter in the DB URI.


git-svn-id: 07e5abd2c6e244bc465bf007dc23a4c6bc1bee58@3524 95a46c32-92d2-0310-94a5-8d71aeb3d4b3
