I have a very simple piece of code :
$dropOrder = new DropOrder($dropOrderId);
$dropOrder->is_supplier_paid = $payValue;
$dropOrder->save();
It works and saves a 'is_supplier_paid' field value into the database. But it also does unexpected actions and fills all null valued fields with 0 values.
I try to save it like this :
$dropOrder->save(true);
But I still have the same strange behavior. I want to change one field only and don't touch the other ones.
Values are formated by ObjectModel::formatValue() before they are inserted / updated, based on the type of the field declared in your $definition.
You have to use TYPE_NOTHING to allow NULL values, it's the only way.
Take a look in Configuration class, with id_shop and id_group_shop fields.
PrestaShop 1.7:
I ran into the same problem in PS 1.7 and set TYPE_NOTHING is not sufficient to resolve this issue. In my case i also needed to add allow_null to true in the field's definition:
'my_field' => ['type' => self::TYPE_NOTHING, 'allow_null' => true, 'value' => null]
('value' => null is probably not necessary but suggested)
Related
(Use Laravel)
I have saved rows in my table. On updating, if I uncheck checkbox, the value must be reset to default. So my checkbox receives only checked values and I take all rows from database and set them to default first, then I set the needed value only for checked rows. This is done in 2 rows of code,
\DB::table('tablename')->where('val', '=', $id)->update(['val' => 0]);
\DB::table('tablename')->whereIn('id', $request->checked)->update(['val' => $id]);
this is one way, but for me it is awful to set all rows to default when I need to set default only not checked ones. The other option is to use foreach, which I don't like in controllers. So question 1 (theoretical and important) - Which takes more resource - huge sql or foreach? Q2 (practical) - how would you solve this problem, considering its Laravel
You could add the inverse of whereIn to your first query.
\DB::table('tablename')
->whereNotIn('id', $request->checked)
->where('val', '=', $id)
->update(['val' => 0]);
My documents have a "Comments" collection, and I'd like to index the "Last Commented Date". I have statically defined index already working for other fields, so there's nothing wrong with my index. But attempting to add this new field is not working. I simply cannot ever get any results when searching by it.
I've tried getting the max date with a Max() aggregation (note that I have to handle cases where there are no comments)
testlastcommented = doc.Comments.Count > 0 ? doc.Comments.Select(c => c.DateEntered).Max() : null
This complains that DynamicList does not support Max(). I could swear that I had an iteration of this using Max() that worked, but now I can't get that working. But regardless even when it wasn't throwing an error, I wasn't able to query on the field.
So then I tried by OrderByDescending/FirstOrDefault as an alternative to Max()
testlastcommented = doc.Comments.OrderByDescending(c => c.DateEntered).FirstOrDefault()
This indexes with no errors. But whatever I do, it's as if the field doesn't exist in the index. I can't get any results with known values.
I broke down and added a calculated "LastCommented" property to the document and indexed that. That obviously works, but I'd rather not have to store a calculated field in the document.
Try this:
testlastcommented = doc.Comments.Select(c => c.DateEntered)
.OrderByDescending(x => x)
.FirstOrDefault()
I am trying to get the ID under "General" from a feature item in rally. This is my query:
body = { "find" => {"_ProjectHierarchy" => projectID, "_TypeHierarchy" => "PortfolioItem/Feature"
},
"fields" => ["FormattedID","Name","State","Release","_ItemHierarchy","_TypeHierarchy","Tags"],
"hydrate" => ["_ItemHierarchy","_TypeHierarchy","Tags"],
"fetch"=>true
}
I am not able to get any value for FormattedID, I tried using "_UnformattedID" but it pulls up an entirely different value than the FormattedID. Any help would be appreciated.
LBAPI does not have FormattedID field. You are correct using _UnformattedID. It is the FormattedID without the prefix. For example, this query:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ProjectHierarchy":2222,"_TypeHierarchy":"PortfolioItem/Feature","State":"Developing",_ValidFrom: {$gte: "2013-06-01TZ",$lt: "2013-09-01TZ"}},sort:{_ValidFrom:-1}}&fields=["_UnformattedID","Name","State"]&hydrate=["State"]&compress=true&pagesize:200
shows _UnformattedID that correspond to FormattedID as this screenshot shows:
I noticed your are using fields and fetch . Per LBAPI's documentation, it uses fields rather than fetch. If you want to get all fields, use fields=true
As far as the missing custom fields, make sure that the custom field value was set within the dates of the query.
Compare these almost identical queries: the first query does not return a custom field, the second query does.
Query #1:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ProjectHierarchy":2222,"_TypeHierarchy":"PortfolioItem/Feature","State":"Developing",_ValidFrom: {$gte: "2013-06-01TZ",$lt: "2013-09-01TZ"}}}&fields=["_UnformattedID","Name","State","c_PiCustomField"]&hydrate=["State","c_PiCustomField"]
Query #2:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/11111/artifact/snapshot/query.js?find={"_ProjectHierarchy":2222,"_TypeHierarchy":"PortfolioItem/Feature","State":"Developing",__At: "current"}&fields=["_UnformattedID","Name","State","c_PiCustomField"]&hydrate=["State","c_PiCustomField"]
The first query uses time period: _ValidFrom: {$gte: "2013-06-01TZ",$lt: "2013-09-01TZ"}
The second query uses __At: "current"
Let's say I just create a new custom field on PortfolioItem. It is not possible to create a custom field on PorfolioItem/Feature, so the field is created on PI, but both queries still use "_TypeHierarchy":"PortfolioItem/Feature".
After I created this custom field, called PiCustomField, I set a value of that field for a specific Feature, F4.
The first query does not have a single snapshot that includes that field because that field did not exist in the time period we lookback. We can't change the past.
The second query returns this field for F4. It does not return it for other Features because all other Features do not have this field set.
Here is the screenshot:
Any of you guys know how to query rally for a set of things where an string attribute value is currently not yet set?
I can’t query for the value equal to an empty string. That doesn’t parse. And I can’t use “null” either. Or rather, I can try “null” and it parses fine but it doesn’t result in finding anything.
query = #rally_api.find(:defect, :fetch =>true,
:project_scope_up => false, :project_scope_down => false,
:workspace => #workspace,
:project => #project) { equals :integration_i_d, "" }
This was followed up by telling the me to substitute "" with nil which didn't work. Null was tried to no success as well. I've tried "null" and null and "". None of them work.
I'm not familiar with our Ruby REST toolkit but directly hitting our WSAPI, you would say (<Field> = null). Notice that there are no quotes around "null".
Also, I'm wondering if the use of contains in your example above is what you wanted. You might want =.
try: { equal :integration_i_d, '""' }
Also, if rally_rest_api seems slow - we're working on something faster here:
http://developer.rallydev.com/help/ruby-rally-api
Im using the symfony framework with mysql.
I have a field in mysql that is generated by doctrine as:
weight: { type: double, notnull: false, default: NULL }
`weight` double(18,2) NULL DEFAULT NULL
The value is entered using a textbox and the generated sql trys to insert '' into this field if no value is given.
This produces the following error:
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'weight' at row 1
How would change this value such that a Doctrine_Null gets used instead?
Also how would i be able to retrieve '(unknown)' for display purposes if the field is null?
Thanks
maybe you could try to use a validator on your form, like sfValidatorNumber ?
http://www.symfony-project.org/api/1_4/sfValidatorNumber
This should happen in your Form/Validation class. If you are expecting to have empty string values submitted then you need to convert those to null as part of this process.
As far as retrieving "unknown" for display i would probably do this as a custom getter on the model class.