@twin.org/entity-storage-connector-mysql 0.0.1-next.24 → 0.0.1-next.25

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.
@@ -469,7 +469,55 @@ class MySqlEntityStorageConnector {
469
469
  const primaryKeys = [];
470
470
  const columnDefinitions = entitySchema.properties
471
471
  .map(prop => {
472
- const sqlType = sqlTypeMap[prop.type] || "TEXT";
472
+ let sqlType = sqlTypeMap[prop.type] || "TEXT";
473
+ if (prop.format) {
474
+ switch (prop.type) {
475
+ case "string":
476
+ sqlType = "LONGTEXT";
477
+ switch (prop.format) {
478
+ case "uuid":
479
+ sqlType = "CHAR(36)";
480
+ break;
481
+ case "date":
482
+ case "date-time":
483
+ sqlType = "LONGTEXT";
484
+ break;
485
+ }
486
+ break;
487
+ case "number":
488
+ sqlType = "FLOAT";
489
+ switch (prop.format) {
490
+ case "float":
491
+ sqlType = "FLOAT";
492
+ break;
493
+ case "double":
494
+ sqlType = "DOUBLE";
495
+ break;
496
+ }
497
+ break;
498
+ case "integer":
499
+ sqlType = "INT";
500
+ switch (prop.format) {
501
+ case "int8":
502
+ case "uint8":
503
+ sqlType = "TINYINT";
504
+ break;
505
+ case "int16":
506
+ case "uint16":
507
+ sqlType = "SMALLINT";
508
+ break;
509
+ case "int32":
510
+ case "uint32":
511
+ sqlType = "INT";
512
+ break;
513
+ case "int64":
514
+ case "uint64":
515
+ sqlType = "BIGINT";
516
+ break;
517
+ }
518
+ break;
519
+ }
520
+ }
473
521
  const columnName = String(prop.property);
474
522
  const nullable = prop.optional ? " NULL" : " NOT NULL";
475
523
  if (prop.isPrimary) {
@@ -467,7 +467,55 @@ class MySqlEntityStorageConnector {
467
467
  const primaryKeys = [];
468
468
  const columnDefinitions = entitySchema.properties
469
469
  .map(prop => {
470
- const sqlType = sqlTypeMap[prop.type] || "TEXT";
470
+ let sqlType = sqlTypeMap[prop.type] || "TEXT";
471
+ if (prop.format) {
472
+ switch (prop.type) {
473
+ case "string":
474
+ sqlType = "LONGTEXT";
475
+ switch (prop.format) {
476
+ case "uuid":
477
+ sqlType = "CHAR(36)";
478
+ break;
479
+ case "date":
480
+ case "date-time":
481
+ sqlType = "LONGTEXT";
482
+ break;
483
+ }
484
+ break;
485
+ case "number":
486
+ sqlType = "FLOAT";
487
+ switch (prop.format) {
488
+ case "float":
489
+ sqlType = "FLOAT";
490
+ break;
491
+ case "double":
492
+ sqlType = "DOUBLE";
493
+ break;
494
+ }
495
+ break;
496
+ case "integer":
497
+ sqlType = "INT";
498
+ switch (prop.format) {
499
+ case "int8":
500
+ case "uint8":
501
+ sqlType = "TINYINT";
502
+ break;
503
+ case "int16":
504
+ case "uint16":
505
+ sqlType = "SMALLINT";
506
+ break;
507
+ case "int32":
508
+ case "uint32":
509
+ sqlType = "INT";
510
+ break;
511
+ case "int64":
512
+ case "uint64":
513
+ sqlType = "BIGINT";
514
+ break;
515
+ }
516
+ break;
517
+ }
518
+ }
471
519
  const columnName = String(prop.property);
472
520
  const nullable = prop.optional ? " NULL" : " NOT NULL";
473
521
  if (prop.isPrimary) {
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/entity-storage-connector-mysql - Changelog
2
2
 
3
- ## v0.0.1-next.24
3
+ ## v0.0.1-next.25
4
4
 
5
5
  - Initial Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-mysql",
3
- "version": "0.0.1-next.24",
3
+ "version": "0.0.1-next.25",
4
4
  "description": "Entity Storage connector implementation using MySQL storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "@twin.org/core": "next",
18
18
  "@twin.org/data-json-ld": "^0.0.1-next.3",
19
19
  "@twin.org/entity": "next",
20
- "@twin.org/entity-storage-models": "0.0.1-next.24",
20
+ "@twin.org/entity-storage-models": "0.0.1-next.25",
21
21
  "@twin.org/logging-models": "next",
22
22
  "@twin.org/nameof": "next",
23
23
  "mysql2": "^3.13.0"