Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Aug 31, 2012
1 parent b5fc23e commit e61d067
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions ckanext/datastore/plugin.py
Expand Up @@ -56,7 +56,7 @@ def new_resource_show(context, data_dict):
try:
connection = engine.connect()
result = connection.execute(
'select * from pg_tables where tablename = %s',
'select 1 from pg_tables where tablename = %s',
new_data_dict['id']
).fetchone()
if result:
Expand All @@ -78,7 +78,7 @@ def new_resource_show(context, data_dict):
def _check_separate_db(self):
'''
Make sure the datastore is on a separate db. Otherwise one could access
all internal tables via the api.
all internal tables via the api.
'''

if self.write_url == self.read_url:
Expand All @@ -95,16 +95,16 @@ def _check_read_permissions(self):
Check whether the right permissions are set for the read only user.
A table is created by the write user to test the read only user.
'''
write_connection = db._get_engine(None,
write_connection = db._get_engine(None,
{'connection_url': self.write_url}).connect()
write_connection.execute(u"CREATE TABLE public.foo (id INTEGER NOT NULL, name VARCHAR)")

read_connection = db._get_engine(None,
read_connection = db._get_engine(None,
{'connection_url': self.read_url}).connect()
read_trans = read_connection.begin()

statements = [
u"CREATE TABLE public.bar (id INTEGER NOT NULL, name VARCHAR)",
u"CREATE TABLE public.bar (id INTEGER NOT NULL, name VARCHAR)",
u"INSERT INTO public.foo VALUES (1, 'okfn')"
]

Expand All @@ -129,7 +129,7 @@ def _check_read_permissions(self):

def _create_alias_table(self):
mapping_sql = '''
SELECT distinct
SELECT distinct
d.refobjid::regclass AS main,
r.ev_class::regclass AS alias
FROM
Expand Down
4 changes: 2 additions & 2 deletions ckanext/datastore/tests/test_datastore.py
Expand Up @@ -271,7 +271,7 @@ def test_guess_types(self):
assert results.rowcount == 3
for i, row in enumerate(results):
assert data['records'][i].get('book') == row['book']
assert data['records'][i].get('author') == (json.loads(row['author'][0]) if row['author'] else None)
assert data['records'][i].get('author') == (json.loads(row['author'][0]) if row['author'] else None)
model.Session.remove()

### extend types
Expand Down Expand Up @@ -802,7 +802,7 @@ def teardown_class(cls):
model.repo.rebuild_db()

def test_is_single_statement(self):
singles = ['SELECT * FROM footable',
singles = ['SELECT * FROM footable',
'SELECT * FROM "bartable"',
'SELECT * FROM "bartable";',
"select 'foo'||chr(59)||'bar'"]
Expand Down

0 comments on commit e61d067

Please sign in to comment.