@truedat/dq 4.56.3 → 4.56.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.56.4] 2022-11-26
4
+
5
+ ### Fixed
6
+
7
+ - [TD-5247] Keep table name if structure field dropdown item changes
8
+
3
9
  ## [4.56.3] 2022-11-24
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dq",
3
- "version": "4.56.3",
3
+ "version": "4.56.4",
4
4
  "description": "Truedat Web Data Quality Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.56.3",
37
+ "@truedat/test": "4.56.4",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -93,8 +93,8 @@
93
93
  },
94
94
  "dependencies": {
95
95
  "@apollo/client": "^3.7.0",
96
- "@truedat/core": "4.56.3",
97
- "@truedat/df": "4.56.3",
96
+ "@truedat/core": "4.56.4",
97
+ "@truedat/df": "4.56.4",
98
98
  "graphql": "^15.5.3",
99
99
  "path-to-regexp": "^1.7.0",
100
100
  "prop-types": "^15.8.1",
@@ -114,5 +114,5 @@
114
114
  "react-dom": ">= 16.8.6 < 17",
115
115
  "semantic-ui-react": ">= 0.88.2 < 2.1"
116
116
  },
117
- "gitHead": "7940a71d7e8ed3eb6c1fc088cf631e37e87fd093"
117
+ "gitHead": "f327860aa80db650f562d53dc22218307f43e0ac"
118
118
  }
@@ -9,26 +9,31 @@ import { linkTo } from "@truedat/core/routes";
9
9
 
10
10
  const concatValues = (values, link) => _.join(link)(values);
11
11
 
12
- const LinkToStructure = ({ value }) =>
12
+ const LinkToStructure = ({ value, aliasArray }) =>
13
13
  value?.id ? (
14
14
  <Link to={linkTo.STRUCTURE({ id: value.id })}>
15
- <span className="highlighted">{`"${
16
- !_.isEmpty(value.path) ? path(value) : value.name
17
- }"`}</span>{" "}
15
+ <div className="highlighted">
16
+ {qualifySqlIdentifier({ aliasArray, value })}
17
+ </div>{" "}
18
18
  </Link>
19
19
  ) : (
20
20
  <span>{value.name}</span>
21
21
  );
22
22
 
23
- const FormattedLink = ({ value, operator = {} }) => {
23
+ LinkToStructure.propTypes = {
24
+ value: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
25
+ aliasArray: PropTypes.array,
26
+ };
27
+
28
+ const FormattedLink = ({ value, aliasArray, operator = {} }) => {
24
29
  switch (operator?.value_type) {
25
30
  case "field":
26
- return <LinkToStructure value={value} />;
31
+ return <LinkToStructure value={value} aliasArray={aliasArray} />;
27
32
  case "field_list":
28
33
  return (
29
34
  <>
30
35
  {_.map.convert({ cap: false })((v, i) => (
31
- <LinkToStructure key={i} value={v} />
36
+ <LinkToStructure key={i} value={v} aliasArray={aliasArray} />
32
37
  ))(value)}
33
38
  </>
34
39
  );
@@ -49,6 +54,7 @@ const FormattedLink = ({ value, operator = {} }) => {
49
54
  FormattedLink.propTypes = {
50
55
  value: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
51
56
  operator: PropTypes.object,
57
+ aliasArray: PropTypes.array,
52
58
  };
53
59
 
54
60
  const nilOrEmpty = (v) => _.isNil(v) || v === "";
@@ -101,7 +107,7 @@ export const getValues = ({ value = [], operator = {}, value_modifier }) => {
101
107
  ? valuesFromKeys(
102
108
  defaultOrValue,
103
109
  ["name"],
104
- ["path", "id", "type", "parent_index"],
110
+ ["path", "metadata", "id", "type", "parent_index"],
105
111
  value_modifier
106
112
  )
107
113
  : valuesFromKeys(defaultOrValue, ["raw"], [], value_modifier);
@@ -124,12 +130,15 @@ OperatorMessage.propTypes = {
124
130
  operator: PropTypes.object,
125
131
  };
126
132
 
133
+ const qualifySqlIdentifier = ({ aliasArray, value }) =>
134
+ _.flow(
135
+ _.find({ index: value?.parent_index }),
136
+ _.propOr(null, "text"),
137
+ _.defaultTo(value?.metadata?.table || _.last(value?.path)),
138
+ (qualifier) => (qualifier ? `(${qualifier}).${value?.name}` : value?.name)
139
+ )(aliasArray);
140
+
127
141
  const ConditionCell = ({ row, alias, validationPopulationCondition }) => {
128
- const alias_text =
129
- _.flow(
130
- _.find({ index: row.structure?.parent_index }),
131
- _.propOr(null, "text")
132
- )(alias) || (row.structure ? _.last(row.structure.path) : null);
133
142
  const values = getValues(row);
134
143
  const operator = _.prop("operator")(row);
135
144
  const { formatMessage } = useIntl();
@@ -154,8 +163,10 @@ const ConditionCell = ({ row, alias, validationPopulationCondition }) => {
154
163
  })}
155
164
  >
156
165
  <span className="highlighted">
157
- {alias_text && `(${alias_text}).`}{" "}
158
- {`"${_.pathOr("", "structure.name")(row)}"`}
166
+ {qualifySqlIdentifier({
167
+ aliasArray: alias,
168
+ value: row.structure,
169
+ })}
159
170
  </span>
160
171
  </Link>
161
172
  </>
@@ -190,8 +201,10 @@ const ConditionCell = ({ row, alias, validationPopulationCondition }) => {
190
201
  })}
191
202
  >
192
203
  <span className="highlighted">
193
- {alias_text && `(${alias_text}).`}{" "}
194
- {`"${_.pathOr("", "name")(row)}"`}
204
+ {qualifySqlIdentifier({
205
+ aliasArray: alias,
206
+ value: row,
207
+ })}
195
208
  </span>
196
209
  </Link>
197
210
  ) : (
@@ -214,7 +227,11 @@ const ConditionCell = ({ row, alias, validationPopulationCondition }) => {
214
227
  <Table.Cell width={5}>
215
228
  {_.map.convert({ cap: false })((value, i) => (
216
229
  <Fragment key={i}>
217
- <FormattedLink value={value} operator={operator} />
230
+ <FormattedLink
231
+ value={value}
232
+ operator={operator}
233
+ aliasArray={alias}
234
+ />
218
235
  {i + 1 < _.size(values) && (
219
236
  <span>
220
237
  {" "}
@@ -266,6 +266,18 @@ describe("<NewRuleImplementation> NewRuleImplementation doSubmit", () => {
266
266
  fields: [
267
267
  {
268
268
  id: 11127109,
269
+ metadata: {
270
+ data_type_class: "string",
271
+ database: "xe",
272
+ default: "None",
273
+ host: "localhost",
274
+ nullable: false,
275
+ order: "4",
276
+ precision: "25",
277
+ schema: "HR",
278
+ table: "EMPLOYEES",
279
+ type: "VARCHAR2",
280
+ },
269
281
  name: "EMAIL",
270
282
  parent_index: 4,
271
283
  path: undefined,
@@ -273,6 +285,18 @@ describe("<NewRuleImplementation> NewRuleImplementation doSubmit", () => {
273
285
  },
274
286
  {
275
287
  id: 11127116,
288
+ metadata: {
289
+ data_type_class: "string",
290
+ database: "xe",
291
+ default: "None",
292
+ host: "localhost",
293
+ nullable: true,
294
+ order: "5",
295
+ precision: "20",
296
+ schema: "HR",
297
+ table: "EMPLOYEES",
298
+ type: "VARCHAR2",
299
+ },
276
300
  name: "PHONE_NUMBER",
277
301
  parent_index: 4,
278
302
  path: undefined,
@@ -59,9 +59,7 @@ exports[`<ConditionSummary /> matches the latest snapshot 1`] = `
59
59
  <span
60
60
  class="highlighted"
61
61
  >
62
- (foo_alias).
63
-
64
- "Mes"
62
+ (foo_alias).Mes
65
63
  </span>
66
64
  </a>
67
65
  </td>
@@ -266,8 +266,7 @@ exports[`<ImplementationSummary /> displays correctly validations values of list
266
266
  <span
267
267
  class="highlighted"
268
268
  >
269
-
270
- "Mes"
269
+ Mes
271
270
  </span>
272
271
  </a>
273
272
  </td>
@@ -629,9 +629,7 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
629
629
  <span
630
630
  class="highlighted"
631
631
  >
632
- (table2).
633
-
634
- "descripcion"
632
+ (table2).descripcion
635
633
  </span>
636
634
  </a>
637
635
  </td>
@@ -650,11 +648,11 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
650
648
  <a
651
649
  href="/structures/4814767"
652
650
  >
653
- <span
651
+ <div
654
652
  class="highlighted"
655
653
  >
656
- "Main &gt; example.txt &gt; external"
657
- </span>
654
+ (FS).external
655
+ </div>
658
656
 
659
657
  </a>
660
658
  </td>
@@ -719,9 +717,7 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
719
717
  <span
720
718
  class="highlighted"
721
719
  >
722
- (FS).
723
-
724
- "agent"
720
+ (FS).agent
725
721
  </span>
726
722
  </a>
727
723
  </td>
@@ -54,6 +54,7 @@ export default function FieldModifier({
54
54
  const pickedValues = _.map(
55
55
  _.pick([
56
56
  "data_structure_id",
57
+ "metadata",
57
58
  "name",
58
59
  "parent_index",
59
60
  "type",
@@ -53,6 +53,7 @@ export const FiltersField = ({
53
53
  const modifierDef = _.find({ name: modifier?.name })(typeCastModifiers);
54
54
  const pickFromValue = _.pick([
55
55
  "data_structure_id",
56
+ "metadata",
56
57
  "name",
57
58
  "parent_index",
58
59
  "type",
@@ -25,7 +25,9 @@ export const FiltersGrid = ({
25
25
 
26
26
  const onStructureChange = (index, value) => {
27
27
  const structure = {
28
- ..._.pick(["field_type", "name", "parent_index", "type"])(value),
28
+ ..._.pick(["field_type", "name", "parent_index", "type", "metadata"])(
29
+ value
30
+ ),
29
31
  id: value.data_structure_id,
30
32
  };
31
33
  setRowValue({
@@ -56,12 +58,21 @@ export const FiltersGrid = ({
56
58
  });
57
59
  };
58
60
 
59
- const composeFieldValue = (value) => ({
60
- id: value.data_structure_id || value.id,
61
- name: value.name,
62
- path: value.path,
63
- parent_index: value.parent_index,
64
- type: value.type,
61
+ const composeFieldValue = ({
62
+ data_structure_id,
63
+ id,
64
+ name,
65
+ path,
66
+ metadata,
67
+ parent_index,
68
+ type,
69
+ }) => ({
70
+ id: data_structure_id || id,
71
+ name,
72
+ path,
73
+ metadata,
74
+ parent_index,
75
+ type,
65
76
  });
66
77
 
67
78
  const composeValue = (value_type, value) => {