@514labs/moose-lib 0.6.433 → 0.6.434

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.
@@ -401,6 +401,18 @@ var handleMaterialized = (t, checker) => {
401
401
  }
402
402
  return materializedType.value;
403
403
  };
404
+ var handleAlias = (t, checker) => {
405
+ const aliasType = getTaggedType(t, checker, "_clickhouse_alias");
406
+ if (aliasType === null) {
407
+ return null;
408
+ }
409
+ if (!aliasType.isStringLiteral()) {
410
+ throw new UnsupportedFeature(
411
+ 'ClickHouseAlias must use a string literal, e.g. ClickHouseAlias<"toDate(timestamp)">'
412
+ );
413
+ }
414
+ return aliasType.value;
415
+ };
404
416
  var handleTtl = (t, checker) => {
405
417
  const ttlType = getTaggedType(t, checker, "_clickhouse_ttl");
406
418
  if (ttlType === null) {
@@ -893,9 +905,18 @@ var toColumns = (t, checker, options) => {
893
905
  );
894
906
  const defaultValue = defaultExpression ?? handleDefault(type, checker);
895
907
  const materializedValue = handleMaterialized(type, checker);
896
- if (defaultValue && materializedValue) {
908
+ const aliasValue = handleAlias(type, checker);
909
+ const setCount = [defaultValue, materializedValue, aliasValue].filter(
910
+ (v) => v != null
911
+ ).length;
912
+ if (setCount > 1) {
913
+ throw new UnsupportedFeature(
914
+ `Column '${prop.name}' can only have one of ClickHouseDefault, ClickHouseMaterialized, or ClickHouseAlias.`
915
+ );
916
+ }
917
+ if (aliasValue != null && isKey) {
897
918
  throw new UnsupportedFeature(
898
- `Column '${prop.name}' cannot have both ClickHouseDefault and ClickHouseMaterialized. Use one or the other.`
919
+ `Column '${prop.name}' cannot be a primary key when using ClickHouseAlias.`
899
920
  );
900
921
  }
901
922
  const docComment = prop.getDocumentationComment(checker);
@@ -908,6 +929,7 @@ var toColumns = (t, checker, options) => {
908
929
  unique: false,
909
930
  default: defaultValue,
910
931
  materialized: materializedValue,
932
+ alias: aliasValue,
911
933
  ttl: handleTtl(type, checker),
912
934
  codec: handleCodec(type, checker),
913
935
  annotations,