forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mysql] Add basic SQL queries (OpenAPITools#5757)
* Add basic SQL queries template * Add namedParametersEnabled option * Move model related SQLs into Model folder * Update README template * Refresh samples
- Loading branch information
Showing
56 changed files
with
1,364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
modules/openapi-generator/src/main/resources/mysql-schema/sql_query.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- | ||
-- {{appName}}.{{#defaultDatabaseName}} | ||
-- Database: `{{{defaultDatabaseName}}}`{{/defaultDatabaseName}} | ||
-- Prepared SQL queries for {{#models}}{{#model}}'{{{name}}}'{{/model}}{{/models}} definition. | ||
-- | ||
|
||
{{#models}}{{#model}} | ||
-- | ||
-- SELECT template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} | ||
-- | ||
SELECT {{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}} FROM {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} | ||
-- | ||
INSERT INTO {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}({{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}}) VALUES ({{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}{{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}}); | ||
|
||
-- | ||
-- UPDATE template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} | ||
-- | ||
UPDATE {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} SET {{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}` = {{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}} WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} | ||
-- | ||
DELETE FROM {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} WHERE 0; | ||
{{/model}}{{/models}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
samples/schema/petstore/mysql/Model/$Special[modelName].sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for '$special[model.name]' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `$special[model.name]` | ||
-- | ||
SELECT `$special[property.name]` FROM `$special[model.name]` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `$special[model.name]` | ||
-- | ||
INSERT INTO `$special[model.name]`(`$special[property.name]`) VALUES (?); | ||
|
||
-- | ||
-- UPDATE template for table `$special[model.name]` | ||
-- | ||
UPDATE `$special[model.name]` SET `$special[property.name]` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `$special[model.name]` | ||
-- | ||
DELETE FROM `$special[model.name]` WHERE 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for '200_response' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `200_response` | ||
-- | ||
SELECT `name`, `class` FROM `200_response` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `200_response` | ||
-- | ||
INSERT INTO `200_response`(`name`, `class`) VALUES (?, ?); | ||
|
||
-- | ||
-- UPDATE template for table `200_response` | ||
-- | ||
UPDATE `200_response` SET `name` = ?, `class` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `200_response` | ||
-- | ||
DELETE FROM `200_response` WHERE 0; | ||
|
26 changes: 26 additions & 0 deletions
26
samples/schema/petstore/mysql/Model/AdditionalPropertiesAnyType.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for 'AdditionalPropertiesAnyType' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `AdditionalPropertiesAnyType` | ||
-- | ||
SELECT `name` FROM `AdditionalPropertiesAnyType` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `AdditionalPropertiesAnyType` | ||
-- | ||
INSERT INTO `AdditionalPropertiesAnyType`(`name`) VALUES (?); | ||
|
||
-- | ||
-- UPDATE template for table `AdditionalPropertiesAnyType` | ||
-- | ||
UPDATE `AdditionalPropertiesAnyType` SET `name` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `AdditionalPropertiesAnyType` | ||
-- | ||
DELETE FROM `AdditionalPropertiesAnyType` WHERE 0; | ||
|
26 changes: 26 additions & 0 deletions
26
samples/schema/petstore/mysql/Model/AdditionalPropertiesArray.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for 'AdditionalPropertiesArray' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `AdditionalPropertiesArray` | ||
-- | ||
SELECT `name` FROM `AdditionalPropertiesArray` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `AdditionalPropertiesArray` | ||
-- | ||
INSERT INTO `AdditionalPropertiesArray`(`name`) VALUES (?); | ||
|
||
-- | ||
-- UPDATE template for table `AdditionalPropertiesArray` | ||
-- | ||
UPDATE `AdditionalPropertiesArray` SET `name` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `AdditionalPropertiesArray` | ||
-- | ||
DELETE FROM `AdditionalPropertiesArray` WHERE 0; | ||
|
26 changes: 26 additions & 0 deletions
26
samples/schema/petstore/mysql/Model/AdditionalPropertiesBoolean.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for 'AdditionalPropertiesBoolean' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `AdditionalPropertiesBoolean` | ||
-- | ||
SELECT `name` FROM `AdditionalPropertiesBoolean` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `AdditionalPropertiesBoolean` | ||
-- | ||
INSERT INTO `AdditionalPropertiesBoolean`(`name`) VALUES (?); | ||
|
||
-- | ||
-- UPDATE template for table `AdditionalPropertiesBoolean` | ||
-- | ||
UPDATE `AdditionalPropertiesBoolean` SET `name` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `AdditionalPropertiesBoolean` | ||
-- | ||
DELETE FROM `AdditionalPropertiesBoolean` WHERE 0; | ||
|
26 changes: 26 additions & 0 deletions
26
samples/schema/petstore/mysql/Model/AdditionalPropertiesClass.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for 'AdditionalPropertiesClass' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `AdditionalPropertiesClass` | ||
-- | ||
SELECT `map_string`, `map_number`, `map_integer`, `map_boolean`, `map_array_integer`, `map_array_anytype`, `map_map_string`, `map_map_anytype`, `anytype_1`, `anytype_2`, `anytype_3` FROM `AdditionalPropertiesClass` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `AdditionalPropertiesClass` | ||
-- | ||
INSERT INTO `AdditionalPropertiesClass`(`map_string`, `map_number`, `map_integer`, `map_boolean`, `map_array_integer`, `map_array_anytype`, `map_map_string`, `map_map_anytype`, `anytype_1`, `anytype_2`, `anytype_3`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); | ||
|
||
-- | ||
-- UPDATE template for table `AdditionalPropertiesClass` | ||
-- | ||
UPDATE `AdditionalPropertiesClass` SET `map_string` = ?, `map_number` = ?, `map_integer` = ?, `map_boolean` = ?, `map_array_integer` = ?, `map_array_anytype` = ?, `map_map_string` = ?, `map_map_anytype` = ?, `anytype_1` = ?, `anytype_2` = ?, `anytype_3` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `AdditionalPropertiesClass` | ||
-- | ||
DELETE FROM `AdditionalPropertiesClass` WHERE 0; | ||
|
26 changes: 26 additions & 0 deletions
26
samples/schema/petstore/mysql/Model/AdditionalPropertiesInteger.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- OpenAPI Petstore. | ||
-- Prepared SQL queries for 'AdditionalPropertiesInteger' definition. | ||
-- | ||
|
||
|
||
-- | ||
-- SELECT template for table `AdditionalPropertiesInteger` | ||
-- | ||
SELECT `name` FROM `AdditionalPropertiesInteger` WHERE 1; | ||
|
||
-- | ||
-- INSERT template for table `AdditionalPropertiesInteger` | ||
-- | ||
INSERT INTO `AdditionalPropertiesInteger`(`name`) VALUES (?); | ||
|
||
-- | ||
-- UPDATE template for table `AdditionalPropertiesInteger` | ||
-- | ||
UPDATE `AdditionalPropertiesInteger` SET `name` = ? WHERE 1; | ||
|
||
-- | ||
-- DELETE template for table `AdditionalPropertiesInteger` | ||
-- | ||
DELETE FROM `AdditionalPropertiesInteger` WHERE 0; | ||
|
Oops, something went wrong.