Issue with InsertOnly command in Ormlite - servicestack

I am using the Servicestack.ormlite package. Everything has been working perfectly, but last night, all of a sudden, my InsertOnly command stopped working. This is the format of the InsertOnly command I am using, straight from the docs: https://github.com/ServiceStack/ServiceStack.OrmLite
Here is the command:
DB.InsertOnly(new ppNomination
{
PortalID = clientID,
NOM_sOtherExperience = nom.Title,
NOM_sExperienceDescription = nom.Description,
NOM_nWitness = nom.Witness,
NOM_dLastUpdated = DateTime.Now,
NOM_WrittenBy = nom.WrittenBy,
NOM_nSteward = nom.Nominee,
NOM_dDeliveredOn = nom.DeliveredOn,
NOM_dCreatedOn = nom.CreatedOn,
NOM_nApprovedBy = nom.ApproverId == -1 ? (int?)null : nom.ApproverId,
NOM_lActive = nom.Active,
NOM_lResubmitted = nom.IsResubmitted,
NOM_lReturned = nom.IsReturned,
NOM_lManagerApproved = nom.IsManagerApproved
},
a => a.Insert(p => new { p.PortalID, p.NOM_sOtherExperience, p.NOM_sExperienceDescription,
p.NOM_nWitness, p.NOM_dLastUpdated, p.NOM_WrittenBy, p.NOM_nSteward, p.NOM_dDeliveredOn,
p.NOM_dCreatedOn, p.NOM_nApprovedBy, p.NOM_lActive, p.NOM_lResubmitted, p.NOM_lReturned,
p.NOM_lManagerApproved }));
nom is the object being passed to the function, and I am just filling it up. This is the error I see:
variable 'p' of type 'Obsidian.Domain.DomainModel.ppNomination' referenced from scope '', but it is not defined
Any ideas as to what I might be doing wrong?

Related

Escaping Dollar Sign Inside Snowflake Javascript Stored Procedure within Terraform

I am trying to incorporate Stored Procedure written in Javascript into Terraform for Snowflake, when I tried to apply script as it was developed I was getting bellow error:
A reference to a resource type must be followed by at least one attribute access, specifying the resource name
Based on the line numbers which raised the error message it does not like the dollar sign, so it seems like it needs to get escaped, example of such un-altered lines are below:
if (rowCount == 0) return `Error: Script with SCRIPT_TYPE = ${SCRIPT_TYPE} and ACCES_TYPE = ${ACCES_TYPE} does not exist.`;
var sql = `select PARAMETER_NAMES, TEMPLATE from administration.utils.SCRIPT_TEMPLATE where SCRIPT_TYPE = ''${SCRIPT_TYPE}'' AND ACCES_TYPE = ''${ACCES_TYPE}''`
What I am after is to know how to escape it and have this logic using the replace function incorporated in procedure resource creation resource "snowflake_procedure" as to be seen below, so that any future changes to the logic or introduction of new procedures does not have to be manually altered, my attempt was to use '\$' for escaping in the function, however not successful:
resource "snowflake_procedure" "GENERATE_SCRIPT_FROM_TEMPLATE" {
name = "GENERATE_SCRIPT_FROM_TEMPLATE"
database = "ADMINISTRATION"
schema = "UTILS"
language = "JAVASCRIPT"
arguments {
SCRIPT_TYPE = "arg1"
type = "VARCHAR(250)"
}
arguments {
ACCES_TYPE = "arg2"
type = "VARCHAR(250)"
}
arguments {
PARAMETER_VALUES = "arg3"
type = "VARCHAR(5000)"
}
return_type = "VARCHAR"
execute_as = "OWNER"
statement = replace(
<<EOT
try
{
var parameterValues = JSON.parse(PARAMETER_VALUES);
}
catch (err) {
return `Failed to parse PARAMETER_VALUES: ${PARAMETER_VALUES}. Correct format is: {"DATABASE": "ADMINISTRATOR", "SCHEMA": "UTILS"}.`;
}
var sql = `select PARAMETER_NAMES, TEMPLATE from administration.utils.SCRIPT_TEMPLATE where SCRIPT_TYPE = ''${SCRIPT_TYPE}'' AND ACCES_TYPE = ''${ACCES_TYPE}''`
var stmt = snowflake.createStatement({ sqlText: sql });
var result = stmt.execute();
var rowCount = result.getRowCount();
if (rowCount == 0) return `Error: Script with SCRIPT_TYPE = ${SCRIPT_TYPE} and ACCES_TYPE = ${ACCES_TYPE} does not exist.`;
result.next();
var parameterNames = result.getColumnValue(1);
var scriptTemplate = result.getColumnValue(2);
var parameterNamesArray = parameterNames.split('','');
parameterNamesArray.forEach(parameterName => {
if (!parameterValues[parameterName]) return `Failed: Cannot find parameter ${parameterName} in PARAMETER_VALUES: ${PARAMETER_VALUES}.`
});
var oldStrimg = '''';
var newString = '''';
var script = scriptTemplate;
parameterNamesArray.forEach(parameterName => {
oldStrimg = `<${parameterName}>`;
newString = parameterValues[parameterName];
script = script.replace(oldStrimg,newString);
});
return script;
EOT
, "$", "'\$'")
}
What I did to escape $$ was to use another sign
For example (sql scripting)
let q := $$ ... ## something ## $$
q := replace(:q, '##', '$$')

How can i simplify checking if a value exist in Json doc

Here is my scenario, i am parsing via javascript a webpage and then post the result to an restApi to store the json in a db. The code works fine as long as all fields i defined in my script are send. Problem is over time they website might change names for fields and that would cause my code to crash.
Originally i used code like this
const mySchool = new mls.School();
mySchool.highSchoolDistrict = data["HIGH SCHOOL DISTRICT"].trim();
mySchool.elementary = data.ELEMENTARY.trim();
mySchool.elementaryOther = data["ELEMENTARY OTHER"].trim();
mySchool.middleJrHigh = data["MIDDLE/JR HIGH"].trim();
mySchool.middleJrHighOther = data["MIDDLE/JR HIGH OTHER"].trim();
mySchool.highSchool = data["HIGH SCHOOL"].trim();
mySchool.highSchoolOther = data["HIGH SCHOOL OTHER"].trim();
newListing.school = mySchool;
but when the element does not exist it complains about that it can not use trim of undefined. So to fix this i came up with this
if (data["PATIO/PORCH"]) {
newExterior.patioPorch = data["PATIO/PORCH"].trim();
}
this works but i am wondering if there is a more global approach then to go and check each field if it is defined ?
You could leverage a sort of helper function to check first if the item is undefined, and if not, return a trim()-ed version of the string.
var data = Array();
data["HIGH SCHOOL DISTRICT"] = " 123 ";
function trimString(inputStr) {
return (inputStr != undefined && typeof inputStr == "string") ? inputStr.trim() : undefined;
}
console.log(trimString(data["HIGH SCHOOL DISTRICT"]));
console.log(trimString(data["ELEMENTARY OTHER"]));

Core Data failing automatic lightweight migration

I'm crashing every time Core Data tries to do an automatic lightweight migration after making a new version of the model (let's call it "Model 2.6") in my app (currently using "Model 2.5").
I've been working with Core Data for a while now, and I'm well aware that any time I need model changes for a new version, I have to use "Editor --> Add Model Version", give that version a new identifier, and switch over to that using the "Current Version" popup. I'm familiar with the "The model used to open the store is incompatible with the one used to create the store" error, because I've made that mistake before. I believe I'm encountering a different problem, though getting that same error message.
After banging my head against this for most of the weekend, I'm hoping someone out there has seen this before and can offer some sage advice.
Here are my steps to trigger the issue:
Reset Simulator, nuke Derived Data, clean build and save a file
with the 2.5 format.
In Xcode, Editor --> Add Model Version...
Use that wizard to make a "Model 2.6" based on "Model 2.5"
Change the new guy's identifier to "2.6"
Do something super-simple to that new version that's totally compatible with automatic lightweight migration, like add an new entity.
Set that "Model 2.6" under the popup for Current Version
Rebuild & launch in the simulator. Crash while opening that 2.5 file I just saved.
I've managed file format updates successfully with nine different releases, and automatic lightweight migration always worked flawlessly, until now.
Differences between now and last time:
Version 2.5 of my model was the first time I set the "Tools Version" to "Automatic (Xcode 8)". All prior releases had this set to "Xcode 7.3" so this will be the first time a migration will happen from a model version already on "Automatic (Xcode 8)"
My xcdatamodeld (and therefore momd file) now lives in my shared framework instead of the host app (so I can share code/resources among extensions, tvOS, etc), though I tried undoing this change to see if it was the cause, and the error still occurs.
I'm honestly not sure. This was supposed to be a trivial hour-long task and it's turned into two days of head-scratching.
Here's the actual error logged after the call to
[_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:self.mainURL options:storeOptions error:&error]
where the storeOptions are { NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; } and for some reason there are two: one for the file .Model.sqlite.migrationdestination_41b5a6b5c6e848c462a8480cd24caef3 and another for the file Model.sqlite, presumably part of the migration process. (Code=134110 with underlying Code=134100)
2016-11-20 16:49:26.928867 Lightbow[27831:356321] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/pwr/Library/Developer/CoreSimulator/Devices/8BDBBB41-ECF6-4646-BA13-DFFD02C40A62/data/Containers/Data/Application/8AE75536-DB51-453F-AEC2-6531F6A0675A/Library/Application%20Support/Lightbow/.Model.sqlite.migrationdestination_41b5a6b5c6e848c462a8480cd24caef3 options:{
NSSQLitePragmasOption = {
"journal_mode" = "<null>";
};
} ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "(null)" UserInfo={metadata={
NSPersistenceFrameworkVersion = 752;
NSStoreModelVersionHashes = {
LBAlarmTrigger = <a84c55da 7fabee63 d6f9965b 4a8408bb aaabc674 bdaff438 347e1ed4 44adb186>;
LBAliasTarget = <d1cdfcbc 1fecf252 1e5ef2e4 6faa5735 6e990645 b8a8a1a6 5db79d93 622ef7af>;
LBAppEventTrigger = <99063c81 4ffe9fec b4092be9 bda6b5cb a1cd8745 400a8a2c 6b44c3e5 abfba541>;
LBAssignment = <bf29b799 abdb6883 0831f861 bb255cf1 5300e503 971ba129 81a18a61 2955eb18>;
LBAudioReference = <0c155311 c41aff4f ebcbea65 1a6ee54a 39039c9a fdcc78e0 d5c21295 38a9069d>;
LBBundledAudioReference = <4c3a5f7b d475af0e df276979 c8ede1cb 24fd616f 7ef33a71 b7302d68 65246848>;
LBCTLightState = <a5c2a06e 72caae63 0b8af8c3 d1be96f0 177ae06e c15120d4 a360b8a0 219c5911>;
LBCollection = <f8c72dfe 0c446e24 0913fcfb f2e603bf 0b3a2d2d 742cda3d 0888d734 2fec4e42>;
LBCollectionItem = <e0a4fd81 4225db2c 5cb0c08d 643324bd 7b23d53a d98deb16 5fa23bf0 a8cdc512>;
LBFadeThroughTransition = <6a37014b c8064ad1 69422f5b d31fa09c 5d61fc01 2b5a50f7 2aadd2e6 76430357>;
LBGroup = <cee84942 402b44d9 905ddb29 84b5f86d d2514f21 e91d9e85 c56c1bd5 de32f3a8>;
LBHSBLightState = <c9926442 5ee27261 c633555a c6259ad9 616b0e23 f5593f5d c82b9f5b 377ff428>;
LBHardwareEventTrigger = <07bd5b0e f52d4701 719c29bc 3a0eed4b b6a93a6d ff596a7d 9b9f98c0 39a805ce>;
LBLight = <4cdd2589 13b20fe0 cc2fa2c6 ce23f092 d45e0bfd 2e5f1421 1be6e0ab a051b6d5>;
LBLightMaster = <95b22dc3 e73a2388 26768e66 1059d41d 40121a30 a3df95da d94649b4 2ed501e8>;
LBLightState = <5e36f926 259d7ef2 8212622c 821182b2 44ade18f 5e8d4fe5 e715f09e 4dc7156f>;
LBMediaItemReference = <28b87019 ffd085e6 944c4a0c fc822b47 68975cff a0ca1484 16888ccf ca89b407>;
LBPreset = <30fa1d52 bac80149 6fee4319 94e16614 cd0830d3 c6414bf6 d48831dc 4a4495b5>;
LBResourceIdentifier = <dedc1079 739eac97 fbc42105 4a64a53e a3ae6c17 00a48ae2 29d30369 e36a3d11>;
LBTimerTrigger = <66736edf 9f104506 e1950ac1 b57062c8 eda65031 d01392ae 51ad7d70 b3143468>;
LBTiming = <362157d7 155e430b 63149c49 5fa84a5f a26a85ee 61ed5748 2f125948 7d4bfeb0>;
LBTransition = <00c8f3a1 fd66426a d0778e83 f51fe772 ab15e7e8 981f2819 aaf10bfc 15384b22>;
LBTrigger = <42c5754c 424e6c9c fc0cf034 e40a4d9c 8fa33236 f9116baa 6c79c248 c6de45d2>;
LBXYLightState = <893ae1a2 4566602f 214572fe aa0eb10f a50e1b1f 2cb5bfff 764892ff 86a62a5b>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"2.5"
);
NSStoreType = SQLite;
NSStoreUUID = "AD94F9C0-947C-4062-A026-253C6DA20AB6";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store} with userInfo dictionary {
metadata = {
NSPersistenceFrameworkVersion = 752;
NSStoreModelVersionHashes = {
LBAlarmTrigger = <a84c55da 7fabee63 d6f9965b 4a8408bb aaabc674 bdaff438 347e1ed4 44adb186>;
LBAliasTarget = <d1cdfcbc 1fecf252 1e5ef2e4 6faa5735 6e990645 b8a8a1a6 5db79d93 622ef7af>;
LBAppEventTrigger = <99063c81 4ffe9fec b4092be9 bda6b5cb a1cd8745 400a8a2c 6b44c3e5 abfba541>;
LBAssignment = <bf29b799 abdb6883 0831f861 bb255cf1 5300e503 971ba129 81a18a61 2955eb18>;
LBAudioReference = <0c155311 c41aff4f ebcbea65 1a6ee54a 39039c9a fdcc78e0 d5c21295 38a9069d>;
LBBundledAudioReference = <4c3a5f7b d475af0e df276979 c8ede1cb 24fd616f 7ef33a71 b7302d68 65246848>;
LBCTLightState = <a5c2a06e 72caae63 0b8af8c3 d1be96f0 177ae06e c15120d4 a360b8a0 219c5911>;
LBCollection = <f8c72dfe 0c446e24 0913fcfb f2e603bf 0b3a2d2d 742cda3d 0888d734 2fec4e42>;
LBCollectionItem = <e0a4fd81 4225db2c 5cb0c08d 643324bd 7b23d53a d98deb16 5fa23bf0 a8cdc512>;
LBFadeThroughTransition = <6a37014b c8064ad1 69422f5b d31fa09c 5d61fc01 2b5a50f7 2aadd2e6 76430357>;
LBGroup = <cee84942 402b44d9 905ddb29 84b5f86d d2514f21 e91d9e85 c56c1bd5 de32f3a8>;
LBHSBLightState = <c9926442 5ee27261 c633555a c6259ad9 616b0e23 f5593f5d c82b9f5b 377ff428>;
LBHardwareEventTrigger = <07bd5b0e f52d4701 719c29bc 3a0eed4b b6a93a6d ff596a7d 9b9f98c0 39a805ce>;
LBLight = <4cdd2589 13b20fe0 cc2fa2c6 ce23f092 d45e0bfd 2e5f1421 1be6e0ab a051b6d5>;
LBLightMaster = <95b22dc3 e73a2388 26768e66 1059d41d 40121a30 a3df95da d94649b4 2ed501e8>;
LBLightState = <5e36f926 259d7ef2 8212622c 821182b2 44ade18f 5e8d4fe5 e715f09e 4dc7156f>;
LBMediaItemReference = <28b87019 ffd085e6 944c4a0c fc822b47 68975cff a0ca1484 16888ccf ca89b407>;
LBPreset = <30fa1d52 bac80149 6fee4319 94e16614 cd0830d3 c6414bf6 d48831dc 4a4495b5>;
LBResourceIdentifier = <dedc1079 739eac97 fbc42105 4a64a53e a3ae6c17 00a48ae2 29d30369 e36a3d11>;
LBTimerTrigger = <66736edf 9f104506 e1950ac1 b57062c8 eda65031 d01392ae 51ad7d70 b3143468>;
LBTiming = <362157d7 155e430b 63149c49 5fa84a5f a26a85ee 61ed5748 2f125948 7d4bfeb0>;
LBTransition = <00c8f3a1 fd66426a d0778e83 f51fe772 ab15e7e8 981f2819 aaf10bfc 15384b22>;
LBTrigger = <42c5754c 424e6c9c fc0cf034 e40a4d9c 8fa33236 f9116baa 6c79c248 c6de45d2>;
LBXYLightState = <893ae1a2 4566602f 214572fe aa0eb10f a50e1b1f 2cb5bfff 764892ff 86a62a5b>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"2.5"
);
NSStoreType = SQLite;
NSStoreUUID = "AD94F9C0-947C-4062-A026-253C6DA20AB6";
"_NSAutoVacuumLevel" = 2;
};
reason = "The model used to open the store is incompatible with the one used to create the store";
}
2016-11-20 16:49:27.027401 Lightbow[27831:356321] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/pwr/Library/Developer/CoreSimulator/Devices/8BDBBB41-ECF6-4646-BA13-DFFD02C40A62/data/Containers/Data/Application/8AE75536-DB51-453F-AEC2-6531F6A0675A/Library/Application%20Support/Lightbow/Model.sqlite options:{
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
} ... returned error Error Domain=NSCocoaErrorDomain Code=134110 "(null)" UserInfo={NSUnderlyingError=0x6000002564a0 {Error Domain=NSCocoaErrorDomain Code=134100 "(null)" UserInfo={metadata={
NSPersistenceFrameworkVersion = 752;
NSStoreModelVersionHashes = {
LBAlarmTrigger = <a84c55da 7fabee63 d6f9965b 4a8408bb aaabc674 bdaff438 347e1ed4 44adb186>;
LBAliasTarget = <d1cdfcbc 1fecf252 1e5ef2e4 6faa5735 6e990645 b8a8a1a6 5db79d93 622ef7af>;
LBAppEventTrigger = <99063c81 4ffe9fec b4092be9 bda6b5cb a1cd8745 400a8a2c 6b44c3e5 abfba541>;
LBAssignment = <bf29b799 abdb6883 0831f861 bb255cf1 5300e503 971ba129 81a18a61 2955eb18>;
LBAudioReference = <0c155311 c41aff4f ebcbea65 1a6ee54a 39039c9a fdcc78e0 d5c21295 38a9069d>;
LBBundledAudioReference = <4c3a5f7b d475af0e df276979 c8ede1cb 24fd616f 7ef33a71 b7302d68 65246848>;
LBCTLightState = <a5c2a06e 72caae63 0b8af8c3 d1be96f0 177ae06e c15120d4 a360b8a0 219c5911>;
LBCollection = <f8c72dfe 0c446e24 0913fcfb f2e603bf 0b3a2d2d 742cda3d 0888d734 2fec4e42>;
LBCollectionItem = <e0a4fd81 4225db2c 5cb0c08d 643324bd 7b23d53a d98deb16 5fa23bf0 a8cdc512>;
LBFadeThroughTransition = <6a37014b c8064ad1 69422f5b d31fa09c 5d61fc01 2b5a50f7 2aadd2e6 76430357>;
LBGroup = <cee84942 402b44d9 905ddb29 84b5f86d d2514f21 e91d9e85 c56c1bd5 de32f3a8>;
LBHSBLightState = <c9926442 5ee27261 c633555a c6259ad9 616b0e23 f5593f5d c82b9f5b 377ff428>;
LBHardwareEventTrigger = <07bd5b0e f52d4701 719c29bc 3a0eed4b b6a93a6d ff596a7d 9b9f98c0 39a805ce>;
LBLight = <4cdd2589 13b20fe0 cc2fa2c6 ce23f092 d45e0bfd 2e5f1421 1be6e0ab a051b6d5>;
LBLightMaster = <95b22dc3 e73a2388 26768e66 1059d41d 40121a30 a3df95da d94649b4 2ed501e8>;
LBLightState = <5e36f926 259d7ef2 8212622c 821182b2 44ade18f 5e8d4fe5 e715f09e 4dc7156f>;
LBMediaItemReference = <28b87019 ffd085e6 944c4a0c fc822b47 68975cff a0ca1484 16888ccf ca89b407>;
LBPreset = <30fa1d52 bac80149 6fee4319 94e16614 cd0830d3 c6414bf6 d48831dc 4a4495b5>;
LBResourceIdentifier = <dedc1079 739eac97 fbc42105 4a64a53e a3ae6c17 00a48ae2 29d30369 e36a3d11>;
LBTimerTrigger = <66736edf 9f104506 e1950ac1 b57062c8 eda65031 d01392ae 51ad7d70 b3143468>;
LBTiming = <362157d7 155e430b 63149c49 5fa84a5f a26a85ee 61ed5748 2f125948 7d4bfeb0>;
LBTransition = <00c8f3a1 fd66426a d0778e83 f51fe772 ab15e7e8 981f2819 aaf10bfc 15384b22>;
LBTrigger = <42c5754c 424e6c9c fc0cf034 e40a4d9c 8fa33236 f9116baa 6c79c248 c6de45d2>;
LBXYLightState = <893ae1a2 4566602f 214572fe aa0eb10f a50e1b1f 2cb5bfff 764892ff 86a62a5b>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
"2.5"
);
NSStoreType = SQLite;
NSStoreUUID = "AD94F9C0-947C-4062-A026-253C6DA20AB6";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}}, reason=Failed to open the store} with userInfo dictionary {
NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134100 \"(null)\" UserInfo={metadata={\n NSPersistenceFrameworkVersion = 752;\n NSStoreModelVersionHashes = {\n LBAlarmTrigger = <a84c55da 7fabee63 d6f9965b 4a8408bb aaabc674 bdaff438 347e1ed4 44adb186>;\n LBAliasTarget = <d1cdfcbc 1fecf252 1e5ef2e4 6faa5735 6e990645 b8a8a1a6 5db79d93 622ef7af>;\n LBAppEventTrigger = <99063c81 4ffe9fec b4092be9 bda6b5cb a1cd8745 400a8a2c 6b44c3e5 abfba541>;\n LBAssignment = <bf29b799 abdb6883 0831f861 bb255cf1 5300e503 971ba129 81a18a61 2955eb18>;\n LBAudioReference = <0c155311 c41aff4f ebcbea65 1a6ee54a 39039c9a fdcc78e0 d5c21295 38a9069d>;\n LBBundledAudioReference = <4c3a5f7b d475af0e df276979 c8ede1cb 24fd616f 7ef33a71 b7302d68 65246848>;\n LBCTLightState = <a5c2a06e 72caae63 0b8af8c3 d1be96f0 177ae06e c15120d4 a360b8a0 219c5911>;\n LBCollection = <f8c72dfe 0c446e24 0913fcfb f2e603bf 0b3a2d2d 742cda3d 0888d734 2fec4e42>;\n LBCollectionItem = <e0a4fd81 4225db2c 5cb0c08d 643324bd 7b23d53a d98deb16 5fa23bf0 a8cdc512>;\n LBFadeThroughTransition = <6a37014b c8064ad1 69422f5b d31fa09c 5d61fc01 2b5a50f7 2aadd2e6 76430357>;\n LBGroup = <cee84942 402b44d9 905ddb29 84b5f86d d2514f21 e91d9e85 c56c1bd5 de32f3a8>;\n LBHSBLightState = <c9926442 5ee27261 c633555a c6259ad9 616b0e23 f5593f5d c82b9f5b 377ff428>;\n LBHardwareEventTrigger = <07bd5b0e f52d4701 719c29bc 3a0eed4b b6a93a6d ff596a7d 9b9f98c0 39a805ce>;\n LBLight = <4cdd2589 13b20fe0 cc2fa2c6 ce23f092 d45e0bfd 2e5f1421 1be6e0ab a051b6d5>;\n LBLightMaster = <95b22dc3 e73a2388 26768e66 1059d41d 40121a30 a3df95da d94649b4 2ed501e8>;\n LBLightState = <5e36f926 259d7ef2 8212622c 821182b2 44ade18f 5e8d4fe5 e715f09e 4dc7156f>;\n LBMediaItemReference = <28b87019 ffd085e6 944c4a0c fc822b47 68975cff a0ca1484 16888ccf ca89b407>;\n LBPreset = <30fa1d52 bac80149 6fee4319 94e16614 cd0830d3 c6414bf6 d48831dc 4a4495b5>;\n LBResourceIdentifier = <dedc1079 739eac97 fbc42105 4a64a53e a3ae6c17 00a48ae2 29d30369 e36a3d11>;\n LBTimerTrigger = <66736edf 9f104506 e1950ac1 b57062c8 eda65031 d01392ae 51ad7d70 b3143468>;\n LBTiming = <362157d7 155e430b 63149c49 5fa84a5f a26a85ee 61ed5748 2f125948 7d4bfeb0>;\n LBTransition = <00c8f3a1 fd66426a d0778e83 f51fe772 ab15e7e8 981f2819 aaf10bfc 15384b22>;\n LBTrigger = <42c5754c 424e6c9c fc0cf034 e40a4d9c 8fa33236 f9116baa 6c79c248 c6de45d2>;\n LBXYLightState = <893ae1a2 4566602f 214572fe aa0eb10f a50e1b1f 2cb5bfff 764892ff 86a62a5b>;\n };\n NSStoreModelVersionHashesVersion = 3;\n NSStoreModelVersionIdentifiers = (\n \"2.5\"\n );\n NSStoreType = SQLite;\n NSStoreUUID = \"AD94F9C0-947C-4062-A026-253C6DA20AB6\";\n \"_NSAutoVacuumLevel\" = 2;\n}, reason=The model used to open the store is incompatible with the one used to create the store}";
reason = "Failed to open the store";
}
Am I missing something obvious when creating this new version? Any other caches or hidden files to clean out? I did notice that when creating a new Whatever.xcdatamodel, a "Discard All Changes..." in Xcode left that file around, so I'm extra careful to delete test runs and check "git status" outside Xcode.
I'm skeptical of the error message because I can switch the xcdatamodeld's "Current Version" back to 2.5, see the file open just fine, switch "Current Version" to 2.6, see it fail, and go back and forth with predictable success/failure. It's clearly able to open 2.5 documents, just somehow not when it's trying to migrate them to 2.6.

OracleBulkCopy error: '0' is not a valid value for 'Interval'

I have the following code
using (OracleConnection srcConn = new OracleConnection())
using (OracleConnection destConn = new OracleConnection())
{
srcConn.ConnectionString = AppInfo.SrcConnStr;
srcConn.Open();
destConn.ConnectionString = AppInfo.DestConnStr;
destConn.Open();
using (OracleCommand destCmd = new OracleCommand("ALTER SESSION SET NLS_DATE_FORMAT = 'yyyy-mm-dd hh24:mi:ss'", destConn))
using (OracleCommand srcCmd = new OracleCommand("ALTER SESSION SET NLS_DATE_FORMAT = 'yyyy-mm-dd hh24:mi:ss'", srcConn))
{
// Non-query
srcCmd.ExecuteNonQuery();
destCmd.ExecuteNonQuery();
if (Timing) { ut.TimeIt(stopwatch, "Get Connection and Command"); }
srcCmd.CommandTimeout = 0;
destCmd.CommandTimeout = 0;
srcCmd.CommandText = "select * from table_name";
rd = srcCmd.ExecuteReader();
rd.FetchSize = rd.RowSize * AppInfo.BatchSize; }
OracleBulkCopy copy = new OracleBulkCopy(destConn);
copy.DestinationTableName = DestTable;
copy.BatchSize = AppInfo.BatchSize;
copy.NotifyAfter = AppInfo.BatchSize;
copy.OracleRowsCopied += new OracleRowsCopiedEventHandler(OnOracleRowsCopied);
copy.BulkCopyTimeout = AppInfo.CommandTimeOut;
copy.WriteToServer(rd);
}
}
When it got to copy.WriteToServer(rd); it gives the following error
System.ArgumentException was caught
Message='0' is not a valid value for 'Interval'. 'Interval' must be greater than 0.
Source=System
StackTrace:
at System.Timers.Timer.set_Interval(Double value)
at Oracle.DataAccess.Client.OracleBulkCopy.PerformBulkCopy()
at Oracle.DataAccess.Client.OracleBulkCopy.WriteDataSourceToServer()
at Oracle.DataAccess.Client.OracleBulkCopy.WriteToServer(IDataReader reader)
My question is, How do I fix it?
Any help is appreciated.
The issue might be setting CommandTimeouts to zero. Try a reasonable number. I think this is specified in seconds.

NpqsqlParameter - Multiple Values

Code:
string sqlCommand = #"UPDATE table SET active = 0 WHERE id IN (#CommaSeparatedId)";
string sqlParamName = "CommaSeparatedId";
string sqlParamValue = "111, 222";
try
{
using (NpgsqlConnection connection = new NpgsqlConnection())
{
// Get connection string from Web.config
connection.ConnectionString = _connectionString;
connection.Open();
Int32 rowsAffected;
using (NpgsqlCommand command = new NpgsqlCommand(sqlCommand, connection))
{
NpgsqlParameter sqlParam = new NpgsqlParameter(sqlParamName, NpgsqlTypes.NpgsqlDbType.Varchar);
// Code below no exception occur, and active not updated to 0
// sqlParam.Value = sqlParamValue;
// This code works for only one value
sqlParam.Value = "111";
command.Parameters.Add(sqlParam);
rowsAffected = command.ExecuteNonQuery();
}
}
}
catch (NpgsqlException pgEx)
{
throw pgEx;
}
The problem is:
If I'm using the 111, 222 as the sqlParam.Value'rowsAffected = 0, but if I'm using only111or222rowsAffected = 1`. That means it success to updated when only 1 value but will failed if trying to update more than 1 value.
Expected Query:
UPDATE table
SET active = 0
WHERE id IN ('111', '222');
What I'm missing in code above?
The problem you are facing is due to the fact that the parameter value "111,222" will be seen by the database engine not like two distinct values, but as one.
The database search for a record with ID = "111,222" and find nothing matching the request.
You should try to use a stored procedure and execute a Dynamic SQL according to the syntax required by PostgreSQL

Resources