@platformatic/sql-mapper 1.5.2 → 1.6.1

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/lib/entity.js CHANGED
@@ -4,6 +4,7 @@ const camelcase = require('camelcase')
4
4
  const {
5
5
  toSingular,
6
6
  toUpperFirst,
7
+ toLowerFirst,
7
8
  tableName,
8
9
  sanitizeLimit
9
10
  } = require('./utils')
@@ -11,11 +12,6 @@ const { singularize } = require('inflected')
11
12
  const { findNearestString } = require('@platformatic/utils')
12
13
  const errors = require('./errors')
13
14
 
14
- function lowerCaseFirst (str) {
15
- str = str.toString()
16
- return str.charAt(0).toLowerCase() + str.slice(1)
17
- }
18
-
19
15
  function createMapper (defaultDb, sql, log, table, fields, primaryKeys, relations, queries, autoTimestamp, schema, useSchemaInName, limitConfig, columns, constraintsList) {
20
16
  /* istanbul ignore next */ // Ignoring because this won't be fully covered by DB not supporting schemas (SQLite)
21
17
  const entityName = useSchemaInName ? toUpperFirst(`${schema}${toSingular(table)}`) : toSingular(table)
@@ -458,7 +454,7 @@ function buildEntity (db, sql, log, table, queries, autoTimestamp, schema, useSc
458
454
  field.foreignKey = true
459
455
  const foreignEntityName = singularize(camelcase(useSchemaInName ? camelcase(`${constraint.foreign_table_schema} ${constraint.foreign_table_name}`) : constraint.foreign_table_name))
460
456
  const entityName = singularize(camelcase(useSchemaInName ? camelcase(`${constraint.table_schema} ${constraint.table_name}`) : constraint.table_name))
461
- const loweredTableWithSchemaName = lowerCaseFirst(useSchemaInName ? camelcase(`${constraint.table_schema} ${camelcase(constraint.table_name)}`) : camelcase(constraint.table_name))
457
+ const loweredTableWithSchemaName = toLowerFirst(useSchemaInName ? camelcase(`${constraint.table_schema} ${camelcase(constraint.table_name)}`) : camelcase(constraint.table_name))
462
458
  constraint.loweredTableWithSchemaName = loweredTableWithSchemaName
463
459
  constraint.foreignEntityName = foreignEntityName
464
460
  constraint.entityName = entityName
package/lib/utils.js CHANGED
@@ -5,9 +5,15 @@ const camelcase = require('camelcase')
5
5
  const errors = require('./errors')
6
6
 
7
7
  function toUpperFirst (str) {
8
+ str = str.toString()
8
9
  return str[0].toUpperCase() + str.slice(1)
9
10
  }
10
11
 
12
+ function toLowerFirst (str) {
13
+ str = str.toString()
14
+ return str.charAt(0).toLowerCase() + str.slice(1)
15
+ }
16
+
11
17
  function toSingular (str) {
12
18
  str = camelcase(singularize(str))
13
19
  str = toUpperFirst(str)
@@ -46,6 +52,7 @@ function areSchemasSupported (sql) {
46
52
  module.exports = {
47
53
  toSingular,
48
54
  toUpperFirst,
55
+ toLowerFirst,
49
56
  sanitizeLimit,
50
57
  tableName,
51
58
  areSchemasSupported
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/sql-mapper",
3
- "version": "1.5.2",
3
+ "version": "1.6.1",
4
4
  "description": "A data mapper utility for SQL databases",
5
5
  "main": "mapper.js",
6
6
  "types": "mapper.d.ts",
@@ -32,7 +32,7 @@
32
32
  "camelcase": "^6.3.0",
33
33
  "fastify-plugin": "^4.5.1",
34
34
  "inflected": "^2.1.0",
35
- "@platformatic/utils": "1.5.2"
35
+ "@platformatic/utils": "1.6.1"
36
36
  },
37
37
  "tsd": {
38
38
  "directory": "test/types"