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

Hints for new features for INSERT #44

Open
pine3ree opened this issue May 1, 2020 · 3 comments
Open

Hints for new features for INSERT #44

pine3ree opened this issue May 1, 2020 · 3 comments

Comments

@pine3ree
Copy link

pine3ree commented May 1, 2020

Hello @wolfy-j ,

just a simple suggestion as it's a feature I implemented many times:

  • add IGNORE for INSERT (just need a boolean like SelectQuery::distinct)
  • add the ability to compile this type of query INSERT INTO table (username, email) SELECT username, email FROM other_table WHERE.... with a new method InsertQuery::select(SelectQuery $select) and building the last part of the INSERT statement with the compiled SELECT statement.

kind regards,
maks

unrelated
  • You can use self as a return type for any public function fluentMethod(): self
  • In php-do blocks it's usually better to use @return $this if the return value is the same instance (and not for instance a clone)
@wolfy-j
Copy link
Member

wolfy-j commented May 1, 2020

All accepted. Injecting SELECT into INSERT is not a problem, we already have such capability on VALUE level.

We will implement this feature somewhere in a future milestone.

@pine3ree
Copy link
Author

pine3ree commented May 1, 2020

Hello @wolfy-j ,

All accepted. Injecting SELECT into INSERT is not a problem, we already have such capability on VALUE level.

but the compiler have this hardcoded string format:
'INSERT INTO %s (%s) VALUES %s',

we need a more flexible format (like selectQuery) to allow:
INSERT{ IGNORE} INTO table{ column_list(...)} {VALUES source_values(...)|SELECT FROM...}

  • the column_list(...) fragment should be optional, even in not INSERT...SELECT statements
  • the last part should allow both (mutually excluding) VALUES and SELECT statements

kind regards

@wolfy-j
Copy link
Member

wolfy-j commented May 2, 2020

Hi, I meant to say that your suggestion was accepted :) It's pretty easy to change the compiler since all the tokens are isolated.

I would appreciate any PR, if not - this feature will be revised in future releases.

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

No branches or pull requests

2 participants