Support for "ignoring a list of specific fields"
See original GitHub issueI was using this tool to generate our regression baselines, the result is a JSON string like:
{
"id": "4163B50C4DD9911804894F827078B218",
"instanceId": "020B24C54D891A89B44AAABDBCFCE057",
"status": 1
}
The problem is that there are some fields such as the instanceId field that is using UUID that will always change, and I don’t want this false alert. One workaround would be:
-
We provide the
ignores=["instanceId",]
to the data_regression function, and the value of this field will be ignored when comparing the result. -
Or, we can replace the value of specific field using special string, such as “{% ignore %}” or something else;
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
java - Testing content of list ignoring some of the fields
One way to do this would be to look for some detail in each element to see which expected element to compare with...
Read more >Ignore fields - Db2 Object Comparison Tool 12.1 - IBM
By using ignore fields, you can compare DB2 catalog records while ignoring some fields. Ignore fields are used in situations where you are...
Read more >Ignoring Fields - Oracle Help Center
Ignoring Fields ; Select Field, then Properties. ; In the Field Properties dialog box, select the Data Load Properties tab. ; Select Ignore...
Read more >Ignore system fields, audit Fields when Extracting fields of an ...
One way to do this is by removing the fields which i dont want from the list. But i want a dynamic way...
Read more >21454 (Ignoring certain fields on INSERT and UPDATE queries)
This could be done by allowing a field to tell django to ignore it on INSERT or UPDATE queries, the same way it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As an idea, I think it would be nice to have a more generic solution that can handle not just ignoring specific fields, but also custom comparison behaviour.
For example, one may want to be able to
id
but assert thatid
field is presentOne way to achive this could be by providing a way to override fields’ values with any object that defines an
__eq__
method. Something likeWe had the same issue using
data_regression
for SQLAlchemy models.Below is a recipe for a new fixture based on
data_regression
that would ignore some fields of the data given to thecheck
method. The recipe uses regex patterns, but I think you can simplify it for your own purpose. You can write this code into your projectconftest.py
, update the class memberfields_to_ignore
and use thedb_model_regression.check
instead.I agree with you that we must find a more elegant way of address that. But I don’t think that adding an
ignores
option is the answer. Maybe adding some highlevel fixtures that knows how to deal with objects instead of dicts. I’ll try to put some thought on it.