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

Compacted-SQL #1153

Closed
wants to merge 3 commits into from
Closed

Compacted-SQL #1153

wants to merge 3 commits into from

Conversation

zhaoxi2000
Copy link

Remove the blank lines in XML
#1126

@harawata
Copy link
Member

harawata commented Dec 8, 2017

String literals should not be modified.

insert into (id, desc) values (1, '----
  some text
---');

All we can do, I think, is to remove leading/trailing whitespaces (i.e. trim()).

@zhaoxi2000
Copy link
Author

zhaoxi2000 commented Dec 10, 2017

@harawata
OK . Let me see....

@zhaoxi2000
Copy link
Author

zhaoxi2000 commented Dec 10, 2017

Update / Insert into , is the values not dynamic ? It would write in XML...
I think it is not actual SQL.

@harawata
Copy link
Member

Hi @zhaoxi1988 ,
Users can write literals (= non-dynamic values) in mapper statements.

@harawata harawata requested review from harawata and removed request for harawata December 11, 2017 17:36
@zhaoxi2000
Copy link
Author

@harawata

What is your idea to handle source-sql in Mapper.xml ?
Only specify the node ?

@harawata
Copy link
Member

I'll comment soon. Sorry for the delay!

@harawata
Copy link
Member

Hi @zhaoxi1988 ,
I forgot to write, thank you for the PR!

Quick question.
If only the first and the last line breaks are removed, is it still useful?

Adding a new option is a big deal to MyBais and this feature has only limited uses, so I wanted to fix this without adding a new option.
But then, we probably cannot remove most line breaks because it could break string literals in SQL.

@zhaoxi2000
Copy link
Author

zhaoxi2000 commented Dec 21, 2017

@harawata It is useful when it occurs at our high concurrent application. We need the SQL in InnoDB log.

Below the question , we can fix it.

it could break string literals in SQL

@harawata
Copy link
Member

Below the question , we can fix it.

it could break string literals in SQL

Are you thinking about parsing SQL?
I hope not because it's a bad idea...

We need the SQL in InnoDB log.

Yes, I think it is a reasonable request.
I'm just not sure what is the best way to support this.

@zhaoxi2000
Copy link
Author

zhaoxi2000 commented Dec 26, 2017

@harawata

It is not very good practice.

insert into (id, desc) values (1, '----
some text
---');

What do you think about that we only specify the <select> node ?

@harawata
Copy link
Member

@zhaoxi1988 ,

Users can write literal values in a SELECT statement, too. :(

It might be possible to write a custom language driver that removes whitespaces.
As it is a user-side solution, you can ignore the tricky literal issue if you don't use it.
I'll look into it once I have time.

@harawata
Copy link
Member

I'm sorry for the lack of response.

I tried to write a custom language driver, but with the current implementation, it requires a lot of copy & paste. :(
I'll ask other devs if they have a good idea.

@zhaoxi2000
Copy link
Author

I'm sorry for the lack of response.

I tried to write a custom language driver, but with the current implementation, it requires a lot of copy & paste. :(
I'll ask other devs if they have a good idea.

Have a good idea to construct this function?

@harbulot
Copy link

Just a quick point about string literals: they're not necessarily within single quotes ('), so relying on SQL parsing would indeed cause further problems.

For example, PostgreSQL can have Dollar-quoted String Constants:

$$Dianne's horse$$
$SomeTag$Dianne's horse$SomeTag$

@harawata
Copy link
Member

Replaced by #1901

@harawata harawata closed this May 18, 2020
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.

None yet

3 participants