Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Adjust Query Representation and SPARQL Query for without state#70

Merged
guergana merged 1 commit into
masterfrom
query-rep-sparql-without-state
Nov 26, 2020
Merged

Adjust Query Representation and SPARQL Query for without state#70
guergana merged 1 commit into
masterfrom
query-rep-sparql-without-state

Conversation

@guergana
Copy link
Copy Markdown
Contributor

@guergana guergana commented Nov 20, 2020

Accidentally worked on this before the ticket was pulled into the sprint. Will leave here for next week

  • added without state to enum
  • modified QueryRepresentation by adding without state
  • added test to verify that query is being generated correctly

@guergana guergana marked this pull request as draft November 20, 2020 14:45
@guergana guergana changed the title [WiP] Adjust Query Representation and SPARQL Query for without state Adjust Query Representation and SPARQL Query for without state Nov 24, 2020
@guergana guergana marked this pull request as ready for review November 24, 2020 14:39
@guergana
Copy link
Copy Markdown
Contributor Author

@Ladsgroup here, ready for review.

},
];

if ( queryRepresentation.condition.propertyValueRelation === PropertyValueRelation.NotMatching ) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is getting quite long. But I think it is still ok and we can refactor it when we get to the multiple conditions.

Comment thread tests/unit/sparql/buildQuery.spec.ts Outdated
const propertyValueRelation = PropertyValueRelation.NotMatching;

/*
* adding an array here to circumvent backticks + indentation problems between
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the more scalable solution might be to just use backticks here and not worry about spaces.

In the assert, we can then replace any whitespace \s+ with a single space ' ' for both the expected and the actual query. See String.prototype.replaceAll()

Copy link
Copy Markdown
Contributor Author

@guergana guergana Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that if you use back ticks then the normal indentation of the code gets added as tabs and it breaks the test. This will probably illustrate the problem better: https://erikmartinjordan.com/avoid-tabs-multiline-string-backticks
Other suggested options would be to use a library, but I thought that might be better solved using native js. https://stackoverflow.com/questions/25924057/multiline-strings-that-dont-break-indentation

Copy link
Copy Markdown
Contributor Author

@guergana guergana Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we can not indent the code but I don't think that's an ideal solution and it would create lint errors. Also leaving it all in one line and adding \n makes the line too long. I tried all different ways and this seems the most decent solution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that these are tests, I wouldn't worry too much. If it gets really big, you can move it a file and read that instead IMO

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote above, we can replace all the whitespace, including any tabs and newlines and such, with a single space before actually asserting the equality. That should ensure that the test still works and still tests that the actual code is equal, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with trim and it didn't work well, will try with replaceAll

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the record, replaceAll is not supported by all browsers and causes the tests to fail. did the same with replace. https://caniuse.com/?search=replaceAll

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to see how replaceAll failed, but I'm fine with just using replace.

Now all that still needs doing is removing this now obsolete commend and then the PR can be approved and merged :)

Copy link
Copy Markdown
Contributor Author

@guergana guergana Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says replaceAll is not a function as the reason for the test to fail. You can try it out. :)
Will delete the comment, thanks for the heads-up.

@Ladsgroup
Copy link
Copy Markdown
Contributor

If Michael is happy, I think it's fine to merge this (my virtual approval)

@guergana guergana force-pushed the query-rep-sparql-without-state branch from 6302e64 to c06e65e Compare November 25, 2020 12:36
+ added without state to enum
+ modified QueryRepresentation by adding without state
+ added test to verify that query is being generated correctly
@guergana guergana force-pushed the query-rep-sparql-without-state branch from c06e65e to bc29ebc Compare November 25, 2020 14:19
@guergana guergana merged commit f41d05d into master Nov 26, 2020
@guergana guergana deleted the query-rep-sparql-without-state branch November 26, 2020 09:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants