Fix issue with missing new added records in download file. #5345
parent
576dc55615
commit
22cdb86aab
|
@ -2098,7 +2098,21 @@ def start_query_download_tool(trans_id):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
sql = None
|
||||||
|
query_commited = data.get('query_commited', False)
|
||||||
|
# Iterate through CombinedMultiDict to find query.
|
||||||
|
for key, value in data.items():
|
||||||
|
if key == 'query':
|
||||||
|
sql = value
|
||||||
|
if key == 'query_commited':
|
||||||
|
query_commited = (
|
||||||
|
eval(value) if isinstance(value, str) else value
|
||||||
|
)
|
||||||
|
if not sql:
|
||||||
|
sql = trans_obj.get_sql(sync_conn)
|
||||||
|
if query_commited:
|
||||||
|
# Re-execute the query to ensure the latest data is included
|
||||||
|
sync_conn.execute_async(sql)
|
||||||
# This returns generator of records.
|
# This returns generator of records.
|
||||||
status, gen, conn_obj = \
|
status, gen, conn_obj = \
|
||||||
sync_conn.execute_on_server_as_csv(records=10)
|
sync_conn.execute_on_server_as_csv(records=10)
|
||||||
|
|
|
@ -47,6 +47,7 @@ export class ResultSetUtils {
|
||||||
this.isQueryTool = isQueryTool;
|
this.isQueryTool = isQueryTool;
|
||||||
this.clientPKLastIndex = 0;
|
this.clientPKLastIndex = 0;
|
||||||
this.historyQuerySource = null;
|
this.historyQuerySource = null;
|
||||||
|
this.hasQueryCommitted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static generateURLReconnectionFlag(baseUrl, transId, shouldReconnect) {
|
static generateURLReconnectionFlag(baseUrl, transId, shouldReconnect) {
|
||||||
|
@ -385,7 +386,17 @@ export class ResultSetUtils {
|
||||||
'trans_id': this.transId
|
'trans_id': this.transId
|
||||||
}),
|
}),
|
||||||
JSON.stringify(reqData)
|
JSON.stringify(reqData)
|
||||||
);
|
).then(response => {
|
||||||
|
if (response.data?.data?.status) {
|
||||||
|
// Set the commit flag to true if the save was successful
|
||||||
|
this.hasQueryCommitted = true;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}).catch((error) => {
|
||||||
|
// Set the commit flag to false if there was an error
|
||||||
|
this.hasQueryCommitted = false;
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveResultsToFile(fileName) {
|
async saveResultsToFile(fileName) {
|
||||||
|
@ -394,7 +405,7 @@ export class ResultSetUtils {
|
||||||
url_for('sqleditor.query_tool_download', {
|
url_for('sqleditor.query_tool_download', {
|
||||||
'trans_id': this.transId,
|
'trans_id': this.transId,
|
||||||
}),
|
}),
|
||||||
{filename: fileName}
|
{filename: fileName, query_commited: this.hasQueryCommitted}
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!_.isUndefined(respData.data)) {
|
if(!_.isUndefined(respData.data)) {
|
||||||
|
@ -402,6 +413,7 @@ export class ResultSetUtils {
|
||||||
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, respData.data.result);
|
this.eventBus.fireEvent(QUERY_TOOL_EVENTS.SET_MESSAGE, respData.data.result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.hasQueryCommitted = false;
|
||||||
let respBlob = new Blob([respData], {type : 'text/csv'}),
|
let respBlob = new Blob([respData], {type : 'text/csv'}),
|
||||||
urlCreator = window.URL || window.webkitURL,
|
urlCreator = window.URL || window.webkitURL,
|
||||||
download_url = urlCreator.createObjectURL(respBlob),
|
download_url = urlCreator.createObjectURL(respBlob),
|
||||||
|
|
|
@ -37,7 +37,8 @@ class TestDownloadCSV(BaseTestGenerator):
|
||||||
is_valid_tx=True,
|
is_valid_tx=True,
|
||||||
is_valid=True,
|
is_valid=True,
|
||||||
download_as_txt=False,
|
download_as_txt=False,
|
||||||
filename='test.csv'
|
filename='test.csv',
|
||||||
|
query_commited=True
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -51,7 +52,8 @@ class TestDownloadCSV(BaseTestGenerator):
|
||||||
is_valid_tx=False,
|
is_valid_tx=False,
|
||||||
is_valid=False,
|
is_valid=False,
|
||||||
download_as_txt=False,
|
download_as_txt=False,
|
||||||
filename='test.csv'
|
filename='test.csv',
|
||||||
|
query_commited=False
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -65,7 +67,8 @@ class TestDownloadCSV(BaseTestGenerator):
|
||||||
is_valid_tx=True,
|
is_valid_tx=True,
|
||||||
is_valid=False,
|
is_valid=False,
|
||||||
download_as_txt=False,
|
download_as_txt=False,
|
||||||
filename='test.csv'
|
filename='test.csv',
|
||||||
|
query_commited=False
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -79,7 +82,8 @@ class TestDownloadCSV(BaseTestGenerator):
|
||||||
is_valid_tx=True,
|
is_valid_tx=True,
|
||||||
is_valid=True,
|
is_valid=True,
|
||||||
download_as_txt=True,
|
download_as_txt=True,
|
||||||
filename=None
|
filename=None,
|
||||||
|
query_commited=False
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
@ -93,7 +97,8 @@ class TestDownloadCSV(BaseTestGenerator):
|
||||||
is_valid_tx=True,
|
is_valid_tx=True,
|
||||||
is_valid=True,
|
is_valid=True,
|
||||||
download_as_txt=False,
|
download_as_txt=False,
|
||||||
filename=None
|
filename=None,
|
||||||
|
query_commited=False
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -184,9 +189,14 @@ class TestDownloadCSV(BaseTestGenerator):
|
||||||
headers['Content-Disposition'])
|
headers['Content-Disposition'])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
data = {
|
||||||
|
"query": self.sql,
|
||||||
|
"filename": self.filename,
|
||||||
|
"query_commited": self.query_commited
|
||||||
|
}
|
||||||
response = self.tester.post(
|
response = self.tester.post(
|
||||||
url,
|
url,
|
||||||
data={"query": self.sql, "filename": self.filename}
|
data=data
|
||||||
)
|
)
|
||||||
headers = dict(response.headers)
|
headers = dict(response.headers)
|
||||||
# Enable the console logging from Flask logger
|
# Enable the console logging from Flask logger
|
||||||
|
|
Loading…
Reference in New Issue