Skip to content

Commit 9f4ccbf

Browse files
committed
chore: fix errors on 2.12
1 parent 8d787c3 commit 9f4ccbf

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

ckanext/xloader/db.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def get_job(job_id):
121121

122122
# Turn the result into a dictionary representation of the job.
123123
result_dict = {}
124-
for field in list(result.keys()):
124+
for field in [c.name for c in JOBS_TABLE.c]:
125125
value = getattr(result, field)
126126
if value is None:
127127
result_dict[field] = value
@@ -448,14 +448,17 @@ def _get_metadata(job_id):
448448

449449
with ENGINE.connect() as conn:
450450
results = conn.execute(
451-
METADATA_TABLE.select().where(
451+
METADATA_TABLE.select().with_only_columns(
452+
METADATA_TABLE.c.key,
453+
METADATA_TABLE.c.value,
454+
METADATA_TABLE.c.type,
455+
).where(
452456
METADATA_TABLE.c.job_id == job_id)).fetchall()
453457
metadata = {}
454-
for row in results:
455-
value = row['value']
456-
if row['type'] == 'json':
458+
for (key, value, value_type) in results:
459+
if value_type == 'json':
457460
value = json.loads(value)
458-
metadata[row['key']] = value
461+
metadata[key] = value
459462
return metadata
460463

461464

ckanext/xloader/jobs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def direct_load(allow_type_guessing=False):
294294
fields=fields,
295295
resource_id=resource['id'],
296296
logger=logger)
297+
297298
update_resource(resource={'id': resource['id'], 'hash': resource['hash']},
298299
patch_only=True)
299300
logger.info('File Hash updated for resource: %s', resource['hash'])

ckanext/xloader/loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def _enable_fulltext_trigger(connection, resource_id):
777777

778778

779779
def _get_rows_count_of_resource(connection, table):
780-
count_query = ''' SELECT count(_id) from {table} '''.format(table=table)
780+
count_query = sa.text(''' SELECT count(_id) from {table} '''.format(table=table))
781781
results = connection.execute(count_query)
782782
rows_count = int(results.first()[0])
783783
return rows_count
@@ -830,7 +830,7 @@ def _populate_fulltext(connection, resource_id, fields, logger):
830830
for start in range(0, rows_count, chunks):
831831
try:
832832
# Build SQL to update _full_text column with concatenated searchable content
833-
sql = \
833+
sql = sa.text(
834834
'''
835835
UPDATE {table}
836836
SET _full_text = to_tsvector({cols}) WHERE _id BETWEEN {first} and {end};
@@ -848,7 +848,7 @@ def _populate_fulltext(connection, resource_id, fields, logger):
848848
),
849849
first=start,
850850
end=start + chunks
851-
)
851+
))
852852
connection.execute(sql)
853853
logger.info("Indexed rows {first} to {end} of {total}".format(
854854
first=start, end=min(start + chunks, rows_count), total=rows_count))

ckanext/xloader/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def set_resource_metadata(update_dict):
273273
for resource in solr_data_dict['resources']:
274274
if resource['id'] == update_dict['resource_id']:
275275
resource.update(update_dict)
276-
psi.index_package(solr_data_dict)
276+
psi.index_package(dict(solr_data_dict, with_custom_schema=solr_data_dict))
277277
break
278278

279279

0 commit comments

Comments
 (0)