petercaogx69 / SQLFormatter

This is a jetbrains development plugin
Apache License 2.0
1 stars 0 forks source link

Plugin does not recognize &gt and &lt in IntelliJ Mybatis Mapper SQL statements #4

Open keeproll opened 3 weeks ago

keeproll commented 3 weeks ago

I am using the plugin very well. I always appreciate it.

There is a problem that the SQL Mapper of IntelliJ does not sort properly in the syntax containing &gt or &lt.

Is there a way to solve this?

Example) -- Original syntax

INSERT INTO traffic_temp
SELECT
organization_id,
device_id,
timestamp_floor('h', ts)
FROM traffic
WHERE ts >= dateadd('h', -1, timestamp_floor('h', now()))
AND ts < timestamp_floor('h', now())
group by organization_id, device_id, timestamp_floor('h', ts);

-- After using SQLFormmater

INSERT INTO traffic_temp
SELECT
  organization_id,
  device_id,
  TIMESTAMP_FLOOR('h',ts)
FROM
  traffic
WHERE
  ts & gt ;
= DATEADD('h',-1,TIMESTAMP_FLOOR('h',NOW() ) ) AND ts & lt;
TIMESTAMP_FLOOR('h',NOW() ) GROUP BY organization_id, device_id, TIMESTAMP_FLOOR('h',ts)
petercaogx69 commented 3 weeks ago

fixed, please try again, by a way, please try my another plugin DaoGenerator, I provide a way to implement your java persistence layer a fresh new solution, Simple and easy to use than MyBatis

keeproll commented 2 weeks ago

Wow! Thank you so much. I'll look into DaoGenerator too! Thanks for the quick fix!

petercaogx69 commented 2 weeks ago

That is to say, the executed SQL is dynamic SQL that changes with the conditions. The dynamic SQL processing solutions of various database persistence are still very different. In the MyBatis framework, dynamic SQL is implemented through template language. Hibernate provides the so-called HQL query language. Practice has proved that this solution can only support a very small subset of SQL query language. JOOQ attempts to provide a series of Java methods to allow programmers to write SQL query statements through programs instead of directly, but this is a disaster for slightly more complex query statements. The Delicacy framework also achieves the goal of dynamic SQL, but its processing method is completely automated