New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@platformatic/sql-mapper

Package Overview
Dependencies
Maintainers
6
Versions
332
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platformatic/sql-mapper - npm Package Compare versions

Comparing version 0.23.1 to 0.23.2

2

lib/queries/shared.js

@@ -80,3 +80,3 @@ 'use strict'

let value = input[key] || input[newKey]
let value = input[key] ?? input[newKey]

@@ -83,0 +83,0 @@ if (value && typeof value === 'object' && !(value instanceof Date)) {

{
"name": "@platformatic/sql-mapper",
"version": "0.23.1",
"version": "0.23.2",
"description": "A data mapper utility for SQL databases",

@@ -5,0 +5,0 @@ "main": "mapper.js",

@@ -53,3 +53,4 @@ 'use strict'

id INTEGER PRIMARY KEY,
the_title VARCHAR(42)
the_title VARCHAR(42),
is_published BOOLEAN NOT NULL
);`)

@@ -59,7 +60,8 @@ } else {

id SERIAL PRIMARY KEY,
the_title VARCHAR(255) NOT NULL
the_title VARCHAR(255) NOT NULL,
is_published BOOLEAN NOT NULL
);`)
}
await db.query(sql`INSERT INTO pages (the_title) VALUES ('foo')`)
await db.query(sql`INSERT INTO pages (the_title) VALUES ('bar')`)
await db.query(sql`INSERT INTO pages (the_title, is_published) VALUES ('foo', true)`)
await db.query(sql`INSERT INTO pages (the_title, is_published) VALUES ('bar', false)`)
}

@@ -75,4 +77,4 @@ const mapper = await connect({

// fixInput
const fixedInput = pageEntity.fixInput({ id: 42, theTitle: 'Fixme' })
same(fixedInput, { id: 42, the_title: 'Fixme' })
const fixedInput = pageEntity.fixInput({ id: 42, theTitle: 'Fixme', isPublished: true })
same(fixedInput, { id: 42, the_title: 'Fixme', is_published: true })

@@ -82,6 +84,7 @@ // fixOutput

id: 42,
the_title: 'Fixme'
the_title: 'Fixme',
is_published: true
})
same(fixedOutput, { id: 42, theTitle: 'Fixme' })
same(fixedOutput, { id: 42, theTitle: 'Fixme', isPublished: true })

@@ -101,25 +104,31 @@ // empty fixOutput

const insertResult = await pageEntity.insert({
inputs: [{ theTitle: 'foobar' }],
fields: ['id', 'theTitle']
inputs: [{ theTitle: 'foobar', isPublished: false }],
fields: ['id', 'theTitle', 'isPublished']
})
same(insertResult, [{ id: '3', theTitle: 'foobar' }])
same(insertResult, [{ id: '3', theTitle: 'foobar', isPublished: false }])
// insert - multiple
const insertMultipleResult = await pageEntity.insert({
inputs: [{ theTitle: 'platformatic' }, { theTitle: 'foobar' }],
fields: ['id', 'theTitle']
inputs: [
{ theTitle: 'platformatic', isPublished: false },
{ theTitle: 'foobar', isPublished: true }
],
fields: ['id', 'theTitle', 'isPublished']
})
same(insertMultipleResult, [{ id: '4', theTitle: 'platformatic' }, { id: '5', theTitle: 'foobar' }])
same(insertMultipleResult, [
{ id: '4', theTitle: 'platformatic', isPublished: false },
{ id: '5', theTitle: 'foobar', isPublished: true }
])
// save - new record
same(await pageEntity.save({
input: { theTitle: 'fourth page' },
fields: ['id', 'theTitle']
}), { id: 6, theTitle: 'fourth page' })
input: { theTitle: 'fourth page', isPublished: false },
fields: ['id', 'theTitle', 'isPublished']
}), { id: 6, theTitle: 'fourth page', isPublished: false })
// save - update record
same(await pageEntity.save({
input: { id: 4, theTitle: 'foofoo' },
fields: ['id', 'theTitle']
}), { id: '4', theTitle: 'foofoo' })
input: { id: 4, theTitle: 'foofoo', isPublished: true },
fields: ['id', 'theTitle', 'isPublished']
}), { id: '4', theTitle: 'foofoo', isPublished: true })

@@ -126,0 +135,0 @@ // save - empty object

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc