문제

When I add or save some data on using JayData and SQL Lite Provider (in phone gap). I get the follwing error:

DefaultError: DEFAULT ERROR CALLBACK!

Exception data: Arguments[1] 0: SQLError code: 0 message: "the statement callback raised an exception or statement error callback did not return false" proto: SQLError ...... length: 1 proto: Object get stack: function () { [native code] } message: "DEFAULT ERROR CALLBACK!" name: "DefaultError" set stack: function () { [native code] } proto: Object jaydata.min.js:53 Guard.raise jaydata.min.js:53 Uncaught DefaultError: DEFAULT ERROR CALLBACK!

However the record is added/updated ok. No idea what the problem could be... any ideas?

The code is:

//Entities:
var Task = $data.Entity.extend("$org.types.Task", {
    Id: { type: "int", key: true },
    TaskType: { type: String, required: false },
    StatusId: { type: "int", required: false },
    DateScheduled:  { type: Date, required: false },
    TimeSlot:  { type: String, required: false },
    LastUpdated:  { type: Date,required: false },
    TaskName:  { type: String, required: false },    
    SpecialInstructions:  { type: String},
    PropertyAddress:  { type: String, required: false },
    PropertyPostCode:  { type: String, required: false },
    PropertyType:  { type: String, required: false },
    NumberOfBedrooms:  { type: "int", required: false },
    HasGarage:  { type: Boolean, required: false },
    HasOutHouse:  { type: Boolean, required: false },
    IsReadyForReportGeneration: {type: Boolean},
    TaskStatus: {type: String},
    DateOfTaskDisplayName: {type: String}
});

//inside a look etc:

taskToUpdate.TaskType = task.TaskType;
                        taskToUpdate.StatusId = task.TaskStatusId;
                        taskToUpdate.TaskStatus = task.TaskStatus;
                        taskToUpdate.DateScheduled = task.Date;
                        taskToUpdate.TimeSlot = task.Time;
                        taskToUpdate.LastUpdated = new Date();
                        taskToUpdate.TaskName = "Job " + task.TaskId + " " + task.TaskType + " @" + task.AddressOfTask + ", " + task.PropertyPostCode;
                        taskToUpdate.SpecialInstructions = specialInstructions;
                        taskToUpdate.PropertyAddress = task.AddressOfTask;
                        taskToUpdate.PropertyPostCode = task.PropertyPostCode;
                        taskToUpdate.PropertyType = task.PropertyType;
                        taskToUpdate.NumberOfBedrooms = task.NumberOfBedrooms;
                        taskToUpdate.HasGarage = task.HasGarage;
                        taskToUpdate.HasOutHouse = task.HasOutHouse;
                        taskToUpdate.DateOfTaskDisplayName = task.DateOfTaskDisplayName,
                        taskToUpdate.IsReadyForReportGeneration = task.ReportReady;

                        if (result.length == 0) {
                            $org.context.Task.add(taskToUpdate);
                        }

                        rowsProcessed++;

                        if (rowsProcessed == rowsToProcess) {
                            $org.context.saveChanges({
                                success: function(db) {
                                    viewModel.messages.push({message:"Tasks saved to local device."});
                                    showNotificationInfo("Tasks saved to local device.");
                                    hideLoader();
                                }, error: function(err) {
                                    console.log(err);
                                    viewModel.messages.push({message:"Errors saving tasks: " + err});
                                    showNotificationError("Errors saving tasks: " + err);   
                                    hideLoader();
                                }
                            });  
                        }
도움이 되었습니까?

해결책 2

RIght It turned out I was calling a method --logInfo(message) that was calling context.savechanges() too.

By calling this with the log create message, it was causing the error... however all the data was saved ok so I'm still a little unsure what was really going on...

I've now made sure that savechanges() is only called after all work is done and only called once...

Thanks for helping out people ...

다른 팁

The problem seems to occur because you don't have any Id set in case you add the new record. The fix for this is easy:

if (result.length == 0) {
  taskToUpdate.Id = task.Id;
  $org.context.Task.add(taskToUpdate);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top