I have a Python script that uses raw SQL to insert records into the database. The SQL is
INSERT INTO `tabBatch Process Documents`
SELECT name AS name,
Now() AS creation,
Now() AS modified,
'Administrator' AS modified_by,
'Administrator' AS owner,
docstatus,
batch_id AS parent,
'batch_docs' AS parentfield,
'Batch Process' AS parenttype,
1 AS idx,
bill_no AS document_name,
bill_date AS document_date,
'Purchase Invoice' AS batch_type
FROM `tabPurchase Invoice`
WHERE docstatus = 0
However, when this query runs, it inserts the data as follows:
SELECT * FROM `tabBatch Process Documents` \G;
*************************** 1. row ***************************
name: PINV-00001
creation: 2018-02-08 09:29:14.000000
modified: 2018-02-08 09:29:14.000000
modified_by: Administrator
owner: Administrator
docstatus: 0
parent: Test Batch
parentfield: batch_docs
parenttype: Batch Process
idx: 1
batch_type: Test 1
document_name: 2018-02-08
document_date: Purchase Invoice
Most of the fields are correct however batch_type, document_name and document_date are in the wrong order. When I ran the select part of the query on it’s own, the data returned from tabPurchase Invoice
was as expected.
Any ideas what might be causing this?
EDIT: For reference, this only happens on production, it works as intended on development