corbinrobb commented on a change in pull request #18056:
URL: https://github.com/apache/superset/pull/18056#discussion_r806377333
##########
File path: superset-frontend/src/views/CRUD/utils.tsx
##########
@@ -33,6 +33,35 @@ import { FetchDataConfig } from 'src/components/ListView';
import SupersetText from 'src/utils/textUtils';
import { Dashboard, Filters } from './types';
+// Modifies the rison encoding slightly to match the backend's
+// rison encoding/decoding. Applies globally. Code pulled from rison.js
+(() => {
Review comment:
This function should only run once and since it doesn't get named,
exported, or called anywhere else, it shouldn't run again. This just takes
advantage of the rison object being global and mutable, and changes the regex
variable on it that decides what to do with certain characters when it
encodes/decodes. That regex variable gets used every time encode_uri, encode or
decode is called but this function itself doesn't
##########
File path: superset-frontend/src/views/CRUD/utils.tsx
##########
@@ -33,6 +33,35 @@ import { FetchDataConfig } from 'src/components/ListView';
import SupersetText from 'src/utils/textUtils';
import { Dashboard, Filters } from './types';
+// Modifies the rison encoding slightly to match the backend's
+// rison encoding/decoding. Applies globally. Code pulled from rison.js
Review comment:
Sure thing! I will have that pushed up soon
##########
File path: superset-frontend/src/views/CRUD/utils.test.tsx
##########
@@ -171,3 +172,21 @@ test('does not ask for password when the import type is
wrong', () => {
};
expect(hasTerminalValidation(error.errors)).toBe(true);
});
+
+test('successfully modified rison to encode correctly', () => {
+ const problemCharacters = '& # ? ^ { } [ ] | " = + `';
+
+ const testObject = problemCharacters.split(' ').reduce((a, c) => {
+ // eslint-disable-next-line no-param-reassign
+ a[c] = c;
+ return a;
+ }, {});
+
+ const actualEncoding = rison.encode(testObject);
+
+ const expectedEncoding =
+
"('\"':'\"','#':'#','&':'&','+':'+','=':'=','?':'?','[':'[',']':']','^':'^','`':'`','{':'{','|':'|','}':'}')";
Review comment:
I can have it make and encode an object for each one of the characters
being tested instead of having it all in one. It will get rid of this big
string and should be easier to read. I am pushing it up now so let me know if
it needs more work and I can give it another go
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]