We have a brand new XCode app that builds and runs and can read/write single pieces of data to Backendless.
However, we are trying to populate 9 rows of data (3 of one class and 6 of another) and we get a message “Item Error: Data truncation: Data too long for column ‘itemDescription’ at row 1”. There are two classes and about 20 lines of code
Edit: I narrowed this down a bit and updated the code in this post.
This issue occurs when the string being written is > 36 characters. e.g. if the string being written is 37 characters it fails, 36 characters works.
The line that prints the error includes our text
print("Item Error: (fault.message ?? "")") //error occurs here
Backendless Version (3.x / 5.x, Online / Managed / Pro )
BackendlessSwift: 5.7.6
Client SDK (REST / Android / Objective-C / Swift / JS )
Swift
macOS 10.15.3
XCode 11.3.1
Application ID
7CFF6F39-692B-D149-FF34-CE74B7A90500
Expected Behavior
Please describe the expected behavior of the issue, starting from the first action.
We expect data to be written without errors.
Actual Behavior
Please provide a description of what actually happens, working from the same starting point.
When data is written, part of the data writes, the rest of the data fails to write.,
with the below code, the invoice objects are all written successfully. However, the item objects fail to write and throw the error.
There isn’t any other code in the app other than this write and the initializaiton code - which we know works because if we comment out either the invoice or the item writing section it works with the other.
Reproducible Test Case
let inv0 = InvoiceClass(invNum: "inv 0", custName: "Company A") let inv1 = InvoiceClass(invNum: "inv 1", custName: "Company B") let inv2 = InvoiceClass(invNum: "inv 2", custName: "Company C") let i0 = ItemClass(itemNum: "AAAAAAA", itemDesc: "123456789_123456789_123456789_1234567", price: 1149.95) //37 chars fail let i1 = ItemClass(itemNum: "BBBBBBB", itemDesc: "123456789_123456789_123456789_123456", price: 12999.95) //36 chars ok let invoices = [inv0, inv1, inv2] let invoiceDataStore = Backendless.shared.data.of(InvoiceClass.self) invoiceDataStore.createBulk(entities: invoices, responseHandler: { savedObjects in print("Invoice Objects saved") }, errorHandler: { fault in print("Invoice Error: (fault.message ?? "")") }) let items = [i0, i1] let itemDataStore = Backendless.shared.data.of(ItemClass.self) itemDataStore.createBulk(entities: items, responseHandler: { savedObjects in print("Item Objects saved") }, errorHandler: { fault in print("Item Error: (fault.message ?? "")") //error occurs here })
and then two classes
@objcMembers class InvoiceClass: NSObject {
var objectId: String?
var invoiceNumber = ""
var customerName = ""
convenience init(invNum: String, custName: String) {
self.init()
self.invoiceNumber = invNum
self.customerName = custName
}
}
@objcMembers class ItemClass: NSObject {
var objectId: String?
var itemNumber = ""
var itemDescription = ""
var itemPrice = 0.0
convenience init(itemNum: String, itemDesc: String, price: Double) {
self.init()
self.itemNumber = itemNum
self.itemDescription = itemDesc
self.itemPrice = price
}
}