Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

DATE_SUB and DATE_ADD functions #663

Closed
erizocosmico opened this issue Apr 9, 2019 · 0 comments · Fixed by #667
Closed

DATE_SUB and DATE_ADD functions #663

erizocosmico opened this issue Apr 9, 2019 · 0 comments · Fixed by #667
Assignees
Labels
3rd-party Third party compatibility feature

Comments

@erizocosmico
Copy link
Contributor

See src-d/gitbase#784

@erizocosmico erizocosmico added feature 3rd-party Third party compatibility labels Apr 9, 2019
@erizocosmico erizocosmico self-assigned this Apr 9, 2019
erizocosmico added a commit to erizocosmico/go-mysql-server that referenced this issue Apr 10, 2019
Fixes src-d#663

This PR introduces a few new features:
- Correctly parsing interval expressions.
- Allow using the + and - operators to subtract from and add to
  dates. e.g. `'2019-04-10' - INTERVAL 1 DAY`.
- New `DATE_ADD` function, which is essentially the same as
  `DATE + INTERVAL`.
- New `DATE_SUB` function, which is essentially the same as
  `DATE - INTERVAL`.
- Validation rule to ensure intervals are only used in certain
  specific places, such as DATE_SUB, DATE_ADD, + and -. Using it
  anywhere else is not valid SQL, but vitess does not catch those
  errors. Plus, even if it's an expression for convenience, its
  `Eval` method is a stub and panics, so it should not be used
  unless it's in an expression that knows how to deal with intervals.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
erizocosmico added a commit to erizocosmico/go-mysql-server that referenced this issue Apr 10, 2019
Fixes src-d#663

This PR introduces a few new features:
- Correctly parsing interval expressions.
- Allow using the + and - operators to subtract from and add to
  dates. e.g. `'2019-04-10' - INTERVAL 1 DAY`.
- New `DATE_ADD` function, which is essentially the same as
  `DATE + INTERVAL`.
- New `DATE_SUB` function, which is essentially the same as
  `DATE - INTERVAL`.
- Validation rule to ensure intervals are only used in certain
  specific places, such as DATE_SUB, DATE_ADD, + and -. Using it
  anywhere else is not valid SQL, but vitess does not catch those
  errors. Plus, even if it's an expression for convenience, its
  `Eval` method is a stub and panics, so it should not be used
  unless it's in an expression that knows how to deal with intervals.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
erizocosmico added a commit to erizocosmico/go-mysql-server that referenced this issue Apr 10, 2019
Fixes src-d#663

This PR introduces a few new features:
- Correctly parsing interval expressions.
- Allow using the + and - operators to subtract from and add to
  dates. e.g. `'2019-04-10' - INTERVAL 1 DAY`.
- New `DATE_ADD` function, which is essentially the same as
  `DATE + INTERVAL`.
- New `DATE_SUB` function, which is essentially the same as
  `DATE - INTERVAL`.
- Validation rule to ensure intervals are only used in certain
  specific places, such as DATE_SUB, DATE_ADD, + and -. Using it
  anywhere else is not valid SQL, but vitess does not catch those
  errors. Plus, even if it's an expression for convenience, its
  `Eval` method is a stub and panics, so it should not be used
  unless it's in an expression that knows how to deal with intervals.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
erizocosmico added a commit to erizocosmico/go-mysql-server that referenced this issue Apr 11, 2019
Fixes src-d#663

This PR introduces a few new features:
- Correctly parsing interval expressions.
- Allow using the + and - operators to subtract from and add to
  dates. e.g. `'2019-04-10' - INTERVAL 1 DAY`.
- New `DATE_ADD` function, which is essentially the same as
  `DATE + INTERVAL`.
- New `DATE_SUB` function, which is essentially the same as
  `DATE - INTERVAL`.
- Validation rule to ensure intervals are only used in certain
  specific places, such as DATE_SUB, DATE_ADD, + and -. Using it
  anywhere else is not valid SQL, but vitess does not catch those
  errors. Plus, even if it's an expression for convenience, its
  `Eval` method is a stub and panics, so it should not be used
  unless it's in an expression that knows how to deal with intervals.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
erizocosmico added a commit to erizocosmico/go-mysql-server that referenced this issue Apr 11, 2019
Fixes src-d#663

This PR introduces a few new features:
- Correctly parsing interval expressions.
- Allow using the + and - operators to subtract from and add to
  dates. e.g. `'2019-04-10' - INTERVAL 1 DAY`.
- New `DATE_ADD` function, which is essentially the same as
  `DATE + INTERVAL`.
- New `DATE_SUB` function, which is essentially the same as
  `DATE - INTERVAL`.
- Validation rule to ensure intervals are only used in certain
  specific places, such as DATE_SUB, DATE_ADD, + and -. Using it
  anywhere else is not valid SQL, but vitess does not catch those
  errors. Plus, even if it's an expression for convenience, its
  `Eval` method is a stub and panics, so it should not be used
  unless it's in an expression that knows how to deal with intervals.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd-party Third party compatibility feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant