Skip to content

Commit

Permalink
Remove usage of postgres' function that's not available in < 9.1
Browse files Browse the repository at this point in the history
The function left() was only added in Postgres 9.1, but we can easily use
substr() to achieve the same effect.

Fixes #542.
  • Loading branch information
vitorbaptista authored and amercader committed Mar 11, 2013
1 parent 26ed1b2 commit 7677d69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckan/migration/versions/067_turn_extras_to_strings.py
Expand Up @@ -7,7 +7,7 @@ def upgrade(migrate_engine):
revision_tables = 'package_extra_revision group_extra_revision'

for table in tables.split():
sql = """select id, value from {table} where left(value,1) = '"' """.format(table=table)
sql = """select id, value from {table} where substr(value,0,1) = '"' """.format(table=table)
results = connection.execute(sql)
for result in results:
id, value = result
Expand All @@ -16,7 +16,7 @@ def upgrade(migrate_engine):
json.loads(value), id)

for table in revision_tables.split():
sql = """select id, revision_id, value from {table} where left(value,1) = '"' """.format(table=table)
sql = """select id, revision_id, value from {table} where substr(value,0,1) = '"' """.format(table=table)

results = connection.execute(sql)
for result in results:
Expand Down

0 comments on commit 7677d69

Please sign in to comment.