- Add provider contract (src/providers/provider.js): query() -> {rows,
rowsAffected, insertId}, callback transaction(fn), exec() for stored
procs, initialize/purge lifecycle
- Add MssqlProvider (src/providers/mssql/index.js) wrapping an mssql
ConnectionPool with normalized results, tx commit/rollback and
constraint-error classifiers (unique 2627/2601, FK 547)
- LibDashStore constructor now takes a provider instead of a pool
(breaking); adds LibDashStore.create() async factory; keeps pool as
transitional bridge until store modules are converted (see TODO.md)
- Move MSSQL-specific code into the provider: src/sql/* ->
src/providers/mssql/queries/*, src/schema.js ->
src/providers/mssql/schema.js, purge SQL -> purgeSql.js
- Update scripts, generate-schema-graph.js and package.json exports
(./providers/mssql, ./providers/provider)
- Add TODO.md with the remaining provider/SQLite migration plan
No SQL or behavioral changes.
51 lines
1022 B
JavaScript
51 lines
1022 B
JavaScript
export const UNIT_COLUMNS = `
|
|
u.si,
|
|
u.basesi,
|
|
u.basesifactor,
|
|
ut.symbol,
|
|
ut.name
|
|
`;
|
|
|
|
export const GET_BY_SI = `
|
|
SELECT id
|
|
FROM unit
|
|
WHERE company_id = @companyId AND si = @si
|
|
`;
|
|
|
|
export const GET_FULL_BY_SI = `
|
|
SELECT
|
|
u.id,
|
|
${UNIT_COLUMNS}
|
|
FROM unit u
|
|
LEFT JOIN unittext ut
|
|
ON ut.unit_id = u.id AND ut.language_id = @languageId
|
|
WHERE u.company_id = @companyId AND u.si = @si
|
|
`;
|
|
|
|
export const LIST_BY_COMPANY = `
|
|
SELECT
|
|
${UNIT_COLUMNS}
|
|
FROM unit u
|
|
LEFT JOIN unittext ut
|
|
ON ut.unit_id = u.id AND ut.language_id = @languageId
|
|
WHERE u.company_id = @companyId
|
|
ORDER BY ut.symbol, ut.name, u.si
|
|
`;
|
|
|
|
export const CREATE = `
|
|
INSERT INTO unit (company_id, si, basesi, basesifactor)
|
|
OUTPUT INSERTED.id
|
|
VALUES (@companyId, @si, @basesi, @basesifactor)
|
|
`;
|
|
|
|
export const UPDATE_BY_SI = `
|
|
UPDATE unit
|
|
SET basesi = @basesi, basesifactor = @basesifactor
|
|
WHERE company_id = @companyId AND si = @si
|
|
`;
|
|
|
|
export const DELETE_BY_COMPANY_AND_SI = `
|
|
DELETE FROM unit
|
|
WHERE company_id = @companyId AND si = @si
|
|
`;
|