Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with config autoincrements getting too large #2298

Merged
merged 4 commits into from
Apr 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion augur/application/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sqlalchemy as s
from sqlalchemy import or_, and_, update
import json
from typing import List, Any, Optional
import os
Expand Down Expand Up @@ -275,7 +276,24 @@ def add_or_update_settings(self, settings: List[dict]):
setting["type"] = None

#print(f"\nsetting: {settings}")
self.session.insert_data(settings,Config, ["section_name", "setting_name"])
#self.session.insert_data(settings,Config, ["section_name", "setting_name"])

#Check if setting exists.
query = self.session.query(Config).filter(and_(Config.section_name == setting["section_name"],Config.setting_name == setting["setting_name"]) )

if execute_session_query(query, 'first') is None:
self.session.insert_data(setting,Config, ["section_name", "setting_name"])
else:
#If setting exists. use raw update to not increase autoincrement
update_query = (
update(Config)
.where(Config.section_name == setting["section_name"])
.where(Config.setting_name == setting["setting_name"])
.values(value=setting["value"])
)

self.session.execute(update_query)
self.session.commit()


def add_section_from_json(self, section_name: str, json_data: dict) -> None:
Expand Down