@strapi/database 4.0.0 → 4.0.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/jest.config.js ADDED
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const baseConfig = require('../../../jest.base-config');
4
+ const pkg = require('./package');
5
+
6
+ module.exports = {
7
+ ...baseConfig,
8
+ displayName: (pkg.strapi && pkg.strapi.name) || pkg.name,
9
+ roots: [__dirname],
10
+ };
@@ -9,7 +9,7 @@ const getDialectClass = client => {
9
9
  case 'sqlite':
10
10
  return require('./sqlite');
11
11
  default:
12
- throw new Error(`Unknow dialect ${client}`);
12
+ throw new Error(`Unknown dialect ${client}`);
13
13
  }
14
14
  };
15
15
 
@@ -63,7 +63,7 @@ const toStrapiType = column => {
63
63
  return { type: 'bigInteger' };
64
64
  }
65
65
  case 'enum': {
66
- return { type: 'enum' };
66
+ return { type: 'string' };
67
67
  }
68
68
  case 'tinyint': {
69
69
  return { type: 'boolean' };
@@ -34,7 +34,6 @@ class SqliteDialect extends Dialect {
34
34
 
35
35
  getSqlType(type) {
36
36
  switch (type) {
37
- // FIXME: enum must be dealt separately
38
37
  case 'enum': {
39
38
  return 'text';
40
39
  }
@@ -390,7 +390,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
390
390
  const targetMeta = metadata.get(attribute.target);
391
391
 
392
392
  if (!targetMeta) {
393
- throw new Error(`Unknow target ${attribute.target}`);
393
+ throw new Error(`Unknown target ${attribute.target}`);
394
394
  }
395
395
 
396
396
  const joinTableName = _.snakeCase(`${meta.tableName}_${attributeName}_links`);
@@ -137,9 +137,7 @@ module.exports = db => {
137
137
  const diffColumns = (oldColumn, column) => {
138
138
  const changes = [];
139
139
 
140
- const isIgnoredType = ['increments', 'enum'].includes(column.type);
141
-
142
- // NOTE: enum aren't updated, they need to be dropped & recreated. Knex doesn't handle it
140
+ const isIgnoredType = ['increments'].includes(column.type);
143
141
  const oldType = oldColumn.type;
144
142
  const type = db.dialect.getSqlType(column.type);
145
143
 
@@ -113,7 +113,8 @@ const getColumnType = attribute => {
113
113
  // We might want to convert email/password to string types before going into the orm with specific validators & transformers
114
114
  case 'password':
115
115
  case 'email':
116
- case 'string': {
116
+ case 'string':
117
+ case 'enumeration': {
117
118
  return { type: 'string' };
118
119
  }
119
120
  case 'uid': {
@@ -132,15 +133,6 @@ const getColumnType = attribute => {
132
133
  case 'json': {
133
134
  return { type: 'jsonb' };
134
135
  }
135
- case 'enumeration': {
136
- return {
137
- type: 'enum',
138
- args: [
139
- attribute.enum,
140
- /*,{ useNative: true, existingType: true, enumName: 'foo_type', schemaName: 'public' }*/
141
- ],
142
- };
143
- }
144
136
  case 'integer': {
145
137
  return { type: 'integer' };
146
138
  }
@@ -185,7 +177,7 @@ const getColumnType = attribute => {
185
177
  return { type: 'boolean' };
186
178
  }
187
179
  default: {
188
- throw new Error(`Unknow type ${attribute.type}`);
180
+ throw new Error(`Unknown type ${attribute.type}`);
189
181
  }
190
182
  }
191
183
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/database",
3
- "version": "4.0.0",
3
+ "version": "4.0.4",
4
4
  "description": "Strapi's database layer",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -28,7 +28,7 @@
28
28
  "lib": "./lib"
29
29
  },
30
30
  "scripts": {
31
- "test": "echo \"no tests yet\""
31
+ "test:unit": "jest --verbose"
32
32
  },
33
33
  "dependencies": {
34
34
  "date-fns": "2.22.1",
@@ -39,8 +39,8 @@
39
39
  "umzug": "2.3.0"
40
40
  },
41
41
  "engines": {
42
- "node": ">=12.x.x <=16.x.x",
42
+ "node": ">=12.22.0 <=16.x.x",
43
43
  "npm": ">=6.0.0"
44
44
  },
45
- "gitHead": "b181702f0202b2c6d645d42b195a831f25cd0b03"
45
+ "gitHead": "d81919ac2272948b3f5d3b25a4cf8cc7b6994460"
46
46
  }
Binary file