-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/combine #44
Refactor/combine #44
Conversation
src/storage/RuntimeError.ts
Outdated
() => new ReactiveDBError(`Token cannot be combined.`) | ||
export const TOKEN_CONCAT_ERR = | ||
(msg?: string) => { | ||
const errMsg = `Token cannot be concat ${ msg ? `due to: ${ msg }` : '' }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Token cannot be concated' + `${ msg ? ' due to: ' + msg : '' }.`
} | ||
|
||
concat(... selectMetas: Selector<T>[]): Selector<T> { | ||
const equal = selectMetas.every(m => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider:
SELECT * FROM TABLE WHERE id >= 0 SKIP 1 LIMIT 10
SELECT * FROM TABLE WHERE id >= 0 SKIP 2 LIMIT 20
...
these queries will violate constraint of concat
method, maybe we should add a term to check if skip mod limit
is equal to 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limit should be equal here
src/storage/Selector.ts
Outdated
const [ meta ] = metaDatas | ||
const skips = metaDatas | ||
.map(m => m.skip) | ||
.sort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider:
SELECT * FROM TABLE WHER id >= 0 SKIP 10 LIMIT 10
SELECT * FROM TABLE WHER id >= 0 SKIP 20 LIMIT 10
SELECT * FROM TABLE WHER id >= 0 SKIP 30 LIMIT 10
...
SELECT * FROM TABLE WHER id >= 0 SKIP 100 LIMIT 10
after sort => [10, 100, 20, 30, ...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这边 skip
是数字不是字符串吧?
private skip?: number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
9281902
to
8a0c4aa
Compare
cdbee30
to
c5d88e8
Compare
Description
重新定义
combine
并将其重命名为concat
,老的combine
实现保留。Related
#5