I had been developing some base queries for about 6 months prior to the release of 2.2
CREATE CLASS Flag_Definitions EXTENDS V
CREATE PROPERTY Flag_Definitions.V_status EMBEDDEDMAP STRING
CREATE PROPERTY Flag_Definitions.V_branding EMBEDDEDMAP STRING
CREATE PROPERTY Flag_Definitions.Block_type EMBEDDEDMAP STRING
CREATE VERTEX Flag_Definitions SET title = "developer reference for all data flags", V_status = {"ACTIVE":"Normal active record", "SUSPENDED":"Currently inactive record","DELETED":"Discontinued record maintained for archiving"}, Block_type = {"Prop":"Holds text from a data object property","HTML":"Holds basic HTML for content","Container":"Holds other blocks"}
but now I'm getting this error in studio
{"errors":[{"code":400,"reason":400,"content":"Map found but entries are not defined as :\r\n\tDB name=\"TestDB\""}]}
From console, the phrasing is slightly different
Map found but entries are not defined as <key>:<value>
Either way, the format 'SET mapfield = {"key":"val"}' no longer seems to be working, and I can't find an explanation. I even looked into the orient code on github (line 118), but, having 2 parts, the format should be passing the check on line 117.
Solved this one, it has nothing to do with the Flag_Definitions object, but I had a default status flag being applied to all created vertices
CREATE PROPERTY V.flags EMBEDDEDMAP STRING
ALTER PROPERTY V.flags DEFAULT {"status":"ACTIVE"}
The issue is the DEFAULT, which needs to be
DEFAULT '{"status":"ACTIVE"}'
Similarly, I had to change
DEFAULT sysdate() to DEFAULT "sysdate()"
Related
I would like to add custom attributes (or Keywords) to a test which I can access during pytest_runtest_logreport.
What I have been doing currently is to set a marker like this
#pytest.mark.TESTID(98157) for tests and then use this in pytest_runtest_logreport as report.keywords['TESTID'] which returns a tuple of length 1 having value 98157. So far so good.
But when I tried to add another marker with defect ID like this #pytest.mark.JIRA("MyJIRA-124") this report.keywords['JIRA'] this gives me integer 1.
So my question is can we not create parameterized marker with string parameters
AND
If that is the could be the probable workaround for me.
Unfortunately "report" will not have this vaules in default implmentation as it's only a dict with 1 as values for each key (source code)
I think that the easiest workaround would be to change how the "report" is constructed using pytest_runtest_makereport hook. It could be as simple as this:
from _pytest.runner import pytest_runtest_makereport as _makereport
def pytest_runtest_makereport(item, call):
report = _makereport(item, call)
report.keywords = dict(item.keywords)
return report
Then in pytest_runtest_logreport, under report.keyword['JIRA'] you will find MarkInfo object
I have written my own Odoo module where I added a property weight to the product.template model.
The implementation in the Python code is
weight = fields.Float('Weight', digits=(12,4))
I also changed the view so that I can set this value in the form. So I created a new product in the Odoo GUI and set the weight to 7.85. After storing the value, 7.8500 is shown which seems to be reasonable as the definition declares 4 float digits. The value stored in the PostgreSQL is a numeric and the value is 7.8500. So this all seems to be correct.
When I now want to get the product with the Odoo API which is based on XML-RPC I do not get 7.8500 but 7.8500000000000005
<member>
<name>weight</name>
<value><double>7.8500000000000005</double></value>
</member>
So my question is, why is this and how can I prevent this?
EDIT:
This behavior occurs whenever I have 2 decimal places. So when I take 7.8 instead of 7.85 the return value is 7.8.
I try in Grails service save an object to mongodb:
Cover saveCover = new Cover()
saveCover.id = url
saveCover.url = url
saveCover.name = name
saveCover.sku = sku
saveCover.price = price
saveCover.save()
Cover domain looks like this:
class Cover {
String id
String name
String url
String sku
String price
}
So I want to have custom id based on url, but during save process I get error:
Could not commit Datastore transaction; nested exception is
org.grails.datastore.mapping.core.OptimisticLockingException: The
instance was updated by another user while you were editing
But if I didn`t use setters and just pass all values in constructor, the exception is gone. Why?
As reported in the documentation here:
Note that if you manually assign an identifier, then you will need to use the insert method instead of the save method, otherwise GORM can't work out whether you are trying to achieve an insert or an update
so you need to use insert method instead of save when id generator is assigned
cover.insert(failOnError: true)
if you do not define the mapping like this:
static mapping = {
id generator: 'assigned'
}
and will use insert method you'll get an auto-generated objectId:
"_id" : "5496e904e4b03b155725ebdb"
This exception occurs when you assign an id to a new model and try to save it because GORM thinks it should be doing an update.
Why this exception occurs
When I ran into this issue I was using 1.3.0 of the grails-mongo plugin. That uses 1.1.9 of the grails datastore core code. I noticed that the exception gets generated on line 847(ish) of NativeEntryEntityPersister. This code updates an existing domain object in the db.
Above that on line 790 is where isUpdate is created which is used to see if it's an update or not. isInsert is false as it is only true when an insert is forced and readObjectIdentifier will return the id that has been assigned to the object so isUpdate will end up evaluating as true.
Fixing the exception
Thanks to && !isInsert on line 791 if you force an insert the insert code will get called and sure enough the exception will go away. However when I did this the assigned id wasn't saved and instead a generated object id was used. I saw that the fix for this was on line 803 where it checks to see if the generator is set to "assigned".
To fix that you can add the following mapping.
class Cover {
String id
String name
String url
String sku
String price
static mapping = {
id generator: 'assigned'
}
}
A side effect of this is that you will always need to assign an id for new Cover domain objects.
I'm using a plugin and want to perform an action based on the records statuscode value. I've seen online that you can use entity.FormattedValues["statuscode"] to get values from option sets but when try it I get an error saying "The given key was not present in the dictionary".
I know this can happen when the plugin cant find the change for the field you're looking for, but i've already checked that this does exist using entity.Contains("statuscode") and it passes by that fine but still hits this error.
Can anyone help me figure out why its failing?
Thanks
I've not seen the entity.FormattedValues before.
I usually use the entity.Attributes, e.g. entity.Attributes["statuscode"].
MSDN
Edit
Crm wraps many of the values in objects which hold additional information, in this case statuscode uses the OptionSetValue, so to get the value you need to:
((OptionSetValue)entity.Attributes["statuscode"]).Value
This will return a number, as this is the underlying value in Crm.
If you open up the customisation options in Crm, you will usually (some system fields are locked down) be able to see the label and value for each option.
If you need the label, you could either do some hardcoding based on the information in Crm.
Or you could retrieve it from the metadata services as described here.
To avoid your error, you need to check the collection you wish to use (rather than the Attributes collection):
if (entity.FormattedValues.Contains("statuscode")){
var myStatusCode = entity.FormattedValues["statuscode"];
}
However although the SDK fails to confirm this, I suspect that FormattedValues are only ever present for numeric or currency attributes. (Part-speculation on my part though).
entity.FormattedValues work only for string display value.
For example you have an optionset with display names as 1, 2, 3,
The above statement do not recognize these values because those are integers. If You have seen the exact defintion of formatted values in the below link
http://msdn.microsoft.com/en-in/library/microsoft.xrm.sdk.formattedvaluecollection.aspx
you will find this statement is valid for only string display values. If you try to use this statement with Integer values it will throw key not found in dictionary exception.
So try to avoid this statement for retrieving integer display name optionset in your code.
Try this
string Title = (bool)entity.Attributes.Contains("title") ? entity.FormattedValues["title"].ToString() : "";
When you are talking about Option set, you have value and label. What this will give you is the label. '?' will make sure that the null value is never passed.
I have an application that generates Open XML documents with Content Controls.
To create a new Content Control I use Interop and the method ContentControls.Add. This method returns an instance of the added Content Control.
I have some logic that saves the id of the Content Control to reference it later, but in some computers I've been having a weird problem.
When I access the ID property of the Content Control I just created, it returns a string with the numeric id, the problem is that when this value is too big, after I save the document, if I look through the document.xml in the generated document, the <w:id/> element of the <w:sdtPr/> element has a negative value, that is the signed equivalent of the value I got from the Id property of the generated control.
For example:
var contentControl = ContentControls.Add(...);
var contentControlId = contentControl.ID;
// the value of contentControlId is "3440157266"
If I save the document and open it in the Package Explorer, the Id of the Content Control is "-854810030" instead of "3440157266".
What have I figured out is this:
((int)uint.Parse("3440157266")).ToString() returns "-854810030"
Any idea of why this happens? This issue is hard to replicate because I don't control the Id of the generated controls, the Id is automatically generated by the Interop libraries.
When displayed in 32-bit binary format, -854810030 and 3440157266 are just the same!
This problem is mentioned in the MSDN documentation of the ContentControl.ID Property:
When you get the ID property value at runtime, it is returned as an unsigned value. However, when saved into the Office Open XML file format, it is saved as a signed value. If your solution attempts to map programmatically returned values to values saved in the file format, you must check for both the unsigned and signed version of the value obtained from this property.
As Claude Martel mentioned, -854810030 and 3440157266 are ident. You can easily check this by casting the signed Int32 to a unsigned UInt32:
var id = Convert.ToInt32("-854810030 ");
UInt32 uId = (uint) id;
Assert.AreEqual(3440157266, uId);
I've had the very same type of issue in the past. The ID is unreliable as it doesn't seem to perpeturate. What I did instead is stored a name of the Content Control's .Tag so I could access it later.