- 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.
33 lines
701 B
JavaScript
33 lines
701 B
JavaScript
export const GET_NEXT_SORT = `
|
|
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
|
|
FROM articlepic
|
|
WHERE article_id = @articleId
|
|
`;
|
|
|
|
export const ADD = `
|
|
INSERT INTO articlepic (article_id, pic_id, sort)
|
|
VALUES (@articleId, @picId, @sort)
|
|
`;
|
|
|
|
export const LIST_HASHES_BY_ARTICLE = `
|
|
SELECT p.hash AS fullHash
|
|
FROM articlepic ap
|
|
INNER JOIN pic p ON p.id = ap.pic_id
|
|
WHERE ap.article_id = @articleId
|
|
ORDER BY ap.sort ASC, ap.id ASC
|
|
`;
|
|
|
|
export const SET_TEMP_SORTS = `
|
|
UPDATE articlepic
|
|
SET sort = -id
|
|
WHERE article_id = @articleId
|
|
`;
|
|
|
|
export const UPDATE_SORT_BY_HASH = `
|
|
UPDATE ap
|
|
SET sort = @sort
|
|
FROM articlepic ap
|
|
INNER JOIN pic p ON p.id = ap.pic_id
|
|
WHERE ap.article_id = @articleId AND p.hash = @fullHash
|
|
`;
|