Skip to content
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

Safer placeholders #73

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

igrep
Copy link
Contributor

@igrep igrep commented May 17, 2019

Improvements from #70

Left Tasks

  • Some tests doesn't pass. Fix them.
  • Avoid to use toFlat and toAggregated as much as possible: ResultContext should be adapted.
  • Add tests for placeholders.
  • You may want to refactor some type definitions

Improvements from khibino#70

- Wrap everything created from a `Record` with `WithPlaceholderOffsets`.
    - Which can be easily concatenated by `Applicative` combinators such as `<*>`.
    - Better solution than khibino#70 (comment) and khibino#70 (comment)
- (BREAKING CHANGE) Pass placeholders Record directly to `query'` etc.
    - Delete old (and unavailable anymore) placholders-related APIs: `placeholder` and `relation'` etc.

Left Tasks
====

- Some tests doesn't pass. Fix them.
- Avoid to use `toFlat` and `toAggregated` as much as possible: `ResultContext` should be adapted.
- Add tests for placeholders.
- You may want to refactor the design.
@igrep igrep force-pushed the accumulate-ph-offsets branch from 5955279 to 3c7b578 Compare May 17, 2019 08:50
@igrep igrep force-pushed the accumulate-ph-offsets branch 16 times, most recently from 2850800 to 848fcdc Compare May 22, 2019 00:42
@igrep igrep force-pushed the accumulate-ph-offsets branch from 848fcdc to 1e2a7a9 Compare May 22, 2019 01:20
show = showStringSQL . detachPlaceholderOffsets . (`sqlFromRelation` defaultPlaceholders)

defaultPlaceholders :: PersistableWidth t => Record PureOperand t
defaultPlaceholders = pwPlaceholders persistableWidth
Copy link
Contributor Author

@igrep igrep Jun 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this API should be "unsafe".
Because this enables us to refer placeholder Records even when building a Relation () a, which doesn't actually receive any placeholder parameters.

updateContext = QueryJoin . modify
updateContext :: Monad m => PlaceholderOffsets -> (JoinContext -> JoinContext) -> QueryJoin m ()
updateContext phs f =
QueryJoin $ modify (mapWithPlaceholderOffsets (f *** (phs <>)))
Copy link
Contributor Author

@igrep igrep Jun 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a bug related to this file: there are cases where the predicate of ON clause are not printed though its attached PlaceholderOffsets is appended.
How can I fix?

@igrep
Copy link
Contributor Author

igrep commented Jul 9, 2019

Tests added: igrep#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant