Verification method and device of structured query language, equipment and storage medium

By extracting and verifying operational SQL and query SQL in the code, the inefficiency and omission risk of SQL lookup and verification in the code is solved, and fast and automated SQL verification is achieved.

CN119576789APending Publication Date: 2025-03-07INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411763152.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

It is a lot of work to find operational SQL and query SQL in the code, and there is a risk of omission.

Method used

Provides a verification method of a structured query language, by extracting the target SQL in the current code, determining its corresponding target test case, and determining the verification project based on the test case. For the validation project of SQL class, determine the validation SQL and test data to import SQL and execute these SQLs to obtain the validation results.

Benefits of technology

It realizes fast search and automated verification of operational SQL and query SQL, reducing the workload of manual search and verification, and reducing the risk of omissions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576789A_ABST
    Figure CN119576789A_ABST
Patent Text Reader

Abstract

The invention discloses a structured query language verification method and device, equipment and a storage medium, and relates to the technical field of artificial intelligence, the method comprises the following steps: extracting a target structured query language SQL from a current code, and determining a target test case corresponding to the target SQL; determining a verification item of the target SQL according to the target test case; the verification item is an SQL class, and determining a verification SQL and a test data import SQL corresponding to the target SQL according to the verification item; and executing the verification SQL after executing the test data and importing the test data into the SQL to obtain a verification result of the target SQL. After a to-be-verified target SQL in a current code is determined, a verification item of the target SQL is determined, a verification SQL and a test data import SQL of the target SQL are determined according to the SQL verification item, the test data import SQL and the verification SQL of the target SQL are sequentially executed, a verification result of the target SQL is obtained, and automatic verification of the target SQL is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of artificial intelligence technology, and in particular to a structured query language verification method, device, equipment and storage medium. Background Art

[0002] The functions of the database code include querying, modifying, deleting, and updating database tables. These functions are implemented at the code level by writing code to connect to the database where the table is located, splicing SQL according to business logic, and submitting SQL to the database for execution.

[0003] The SQL that implements these functions is operation-class SQL and query-class SQL. For the verification of operation-class SQL and query-class SQL, testers must first find the operation-class SQL and query-class SQL in the code, and prepare test data and test cases based on the SQL.

[0004] However, it is a lot of work to find the operation-type SQL and query-type SQL in the code, and there is also a risk of omission. Summary of the invention

[0005] The present invention provides a structured query language verification method, device, equipment and storage medium to achieve fast search and automatic verification of operation-type SQL and query-type SQL.

[0006] In a first aspect, an embodiment of the present invention provides a structured query language verification method, comprising:

[0007] Extracting a target structured query language SQL from the current code, and determining a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL;

[0008] Determine the verification items of the target SQL according to the target test case;

[0009] When the verification item is of SQL type, determining the verification SQL and the test data import SQL corresponding to the target SQL according to the verification item;

[0010] After executing the test data import SQL, the verification SQL is executed to obtain the verification result of the target SQL.

[0011] The technical solution of an embodiment of the present invention provides a structured query language verification method, including: extracting a target structured query language SQL in a current code, determining a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL; determining a verification item for the target SQL according to the target test case; when the verification item is an SQL-type, determining a verification SQL and a test data import SQL corresponding to the target SQL according to the verification item; and executing the verification SQL after executing the test data import SQL to obtain a verification result of the target SQL. The above technical scheme can firstly quickly determine the target SQL to be verified in the current code according to the keywords of the operation-type SQL and the query-type SQL, so as to realize the rapid determination of the target SQL. It can also determine the target test case corresponding to the target SQL in the test case library according to the operation type of the target SQL, so as to realize the determination of the target test case required to verify the target SQL. Then, the verification items of the target SQL can be determined according to the target test case corresponding to the target SQL. For the SQL-type verification items, the verification SQL and the test data import SQL corresponding to the target SQL can be determined according to the verification items, so as to provide a code basis for the verification of the target SQL. Then, the test data import SQL and the verification SQL corresponding to the target SQL can be executed in sequence, and the verification of the target SQL can be realized after the operation of the target SQL on the target database is actually executed, so as to obtain the verification result of the target SQL and realize the automatic verification of the target SQL.

[0012] Furthermore, the target SQL is extracted from the current code, including:

[0013] By scanning the current code, determining whether the current code contains keywords of the operation-type SQL and / or the query-type SQL;

[0014] When it is determined that the current code contains the keyword, the code fragment corresponding to the keyword is disassembled and analyzed to obtain an SQL fragment corresponding to the code fragment;

[0015] Determine the parameter annotation of the parameter passing part in the SQL fragment, and splice the SQL fragment and the parameter annotation based on SQL grammar rules to obtain the target SQL.

[0016] Further, determining the target test case corresponding to the target SQL includes:

[0017] Determine the operation type of the target SQL;

[0018] The target test case corresponding to the target SQL is determined in a test case library according to the operation type of the target SQL.

[0019] Further, determining the verification items of the target SQL according to the target test case includes:

[0020] The case description of the target test case is determined as the verification item of the target SQL.

[0021] Furthermore, when extracting the target SQL in the current code, it also includes:

[0022] Determine the target database corresponding to the target SQL;

[0023] Accordingly, after executing the test data import SQL, executing the verification SQL to obtain the verification result of the target SQL includes:

[0024] The test data import SQL and the verification SQL are executed in sequence based on the target database to obtain a verification result of the target SQL.

[0025] Further, after determining the verification items of the target SQL according to the target test case, it also includes:

[0026] When the verification item is of non-SQL type, the verification result of the target SQL is determined by scanning the target SQL.

[0027] In a second aspect, an embodiment of the present invention further provides a structured query language verification device, comprising:

[0028] An extraction module is used to extract a target structured query language SQL from the current code and determine a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL;

[0029] A first determination module, used to determine the verification items of the target SQL according to the target test case;

[0030] A second determination module is used to determine the verification SQL and the test data import SQL corresponding to the target SQL according to the verification project when the verification project is of SQL type;

[0031] The execution module is used to execute the verification SQL after executing the test data import SQL to obtain the verification result of the target SQL.

[0032] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

[0033] at least one processor; and a memory communicatively coupled to the at least one processor;

[0034] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the structured query language verification method as described in any one of the first aspects.

[0035] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the structured query language verification method as described in any one of the first aspects.

[0036] In a fifth aspect, the present application provides a computer program product, which includes computer instructions. When the computer instructions are executed on a computer, the computer executes the structured query language verification method provided in the first aspect.

[0037] It should be noted that the above-mentioned computer instructions may be stored in whole or in part on a computer-readable storage medium. The computer-readable storage medium may be packaged together with the processor of the structured query language verification device, or may be packaged separately from the processor of the structured query language verification device, and this application does not limit this.

[0038] The description of the second, third, fourth and fifth aspects in this application can refer to the detailed description of the first aspect; and the beneficial effects of the description of the second, third, fourth and fifth aspects can refer to the beneficial effect analysis of the first aspect, which will not be repeated here.

[0039] In this application, the name of the verification device of the structured query language does not limit the device or functional module itself. In actual implementation, these devices or functional modules may appear with other names. As long as the functions of each device or functional module are similar to those of this application, they fall within the scope of the claims of this application and their equivalent technologies.

[0040] These and other aspects of the present application will become more apparent from the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0042] Figure 1 A flow chart of a structured query language verification method provided by an embodiment of the present invention;

[0043] Figure 2 A flowchart of another structured query language verification method provided by an embodiment of the present invention;

[0044] Figure 3 A schematic diagram of the structure of a verification device for a structured query language provided by an embodiment of the present invention;

[0045] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0047] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0048] The terms "first" and "second" and the like in the specification and drawings of this application are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.

[0049] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0050] It should be mentioned before discussing exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe various operations (or steps) as sequential processes, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of various operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to methods, functions, procedures, subroutines, subprograms, etc. In addition, the embodiments in the present invention and the features in the embodiments can be combined with each other without conflict.

[0051] It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0052] In the description of the present application, unless otherwise specified, “plurality” means two or more.

[0053] Figure 1 A flow chart of a structured query language verification method provided by an embodiment of the present invention is provided. This embodiment is applicable to situations where it is necessary to verify the target SQL in the code. The method can be executed by a structured query language verification device, such as Figure 1 As shown, the specific steps include:

[0054] Step 110: extract the target structured query language SQL from the current code, and determine the target test case corresponding to the target SQL.

[0055] Among them, the target SQL includes operation-type SQL and / or query-type SQL, the operation-type SQL includes insert SQL, update SQL, create SQL and delete SQL, the query-type SQL includes query SQL, the keyword of insert SQL is INSERT, the keyword of update SQL is UPDATE, the keyword of create SQL is CREATE, the keyword of delete SQL is DELETE, and the keyword of query SQL is SELECT.

[0056] Specifically, the current code may be scanned first, and the target SQL may be determined by parsing code snippets containing operation-type SQL and / or query-type SQL keywords in the current code, and the target database corresponding to the target SQL may also be determined.

[0057] The test case library includes verification items of various types of SQL. When SQL needs to be verified, the corresponding test case can be extracted from the test case library. Therefore, the target test case corresponding to the target SQL can be extracted from the test case library.

[0058] In the embodiment of the present invention, it is possible to quickly determine the target SQL to be verified in the current code, and it is possible to determine the target test case required to verify the target SQL.

[0059] Step 120: Determine the verification items of the target SQL according to the target test case.

[0060] The test case includes description information for the test items, and the verification items can be determined based on this description information. For example, the test case corresponding to the SQL insertion may include: 1) Adding correct data, checking whether the addition of correct data is successful, and specifically querying whether the SQL corresponding data table has new correct data; 2) Adding the same data, if the SQL corresponding data table has a unique index, check whether the addition is successful, if the SQL corresponding data table does not have a unique index, check whether the addition is successful, and specifically query whether the SQL corresponding data table has data, and remind whether a unique constraint needs to be added; 3) Adding wrong data, checking whether the addition of wrong data is successful, and specifically querying whether the SQL corresponding data table has new wrong data; 4) Adding empty data, if the SQL corresponding data table has a non-empty constraint, the data is not added, and querying whether the SQL corresponding data table fails to add the new data, if the SQL corresponding data table does not have a non-empty constraint, add a piece of data, and remind whether a non-empty constraint needs to be added.

[0061] Specifically, after determining the target test case corresponding to the target SQL, the verification items of the target SQL can be determined according to the description information of the test items of the target test case corresponding to the target SQL. For example, it can be determined that the verification items of the inserted SQL include whether the correct data is added successfully, whether the wrong data is added successfully, whether the same data is added successfully, and whether the empty data is added successfully or failed.

[0062] In actual applications, verification items include SQL and non-SQL. SQL verification items require SQL execution to determine the verification results, while non-SQL verification items can determine the verification results without SQL execution.

[0063] In the embodiment of the present invention, the verification items of the target SQL are determined according to the target test cases corresponding to the target SQL.

[0064] Step 130: When the verification item is of SQL type, the verification SQL and the test data import SQL corresponding to the target SQL are determined according to the verification item.

[0065] Specifically, if the verification item is an SQL class, the verification SQL corresponding to the target SQL needs to be executed to determine the verification result of the target SQL. Therefore, the verification SQL corresponding to the target SQL can be determined according to the verification item. Specifically, the corresponding verification SQL can be determined according to the operation type of the target SQL. For example, if the operation type of the target SQL is an insert class, the verification SQL can be determined to be a query SQL for querying the update field to verify whether the inserted data meets the expected result.

[0066] Of course, the target SQL does not contain the data for actual operation. Before the target SQL is verified based on the verification SQL, the test data import SQL corresponding to the target SQL needs to be determined. The test data import SQL can be used to actually perform the operation corresponding to the target SQL on the target database. Specifically, the test data import SQL corresponding to the target SQL can be determined based on the target SQL and the operation of the target SQL on the target database. For example, when the operation of the target SQL on the target database is to insert data, the test data import SQL corresponding to the target SQL can be determined to be the target SQL and the data actually to be inserted.

[0067] In the embodiment of the present invention, the verification SQL corresponding to the SQL-type verification item of the target SQL and the test data import SQL are determined, providing a code basis for the verification of the target SQL.

[0068] Step 140: After executing the test data import SQL, execute the verification SQL to obtain the verification result of the target SQL.

[0069] Specifically, first, the test data import SQL corresponding to the target SQL can be executed to actually execute the operations that the target SQL needs to perform on the target database. Secondly, the verification SQL can be executed to verify the execution result of the test data import SQL. Then, the execution result of the test data import SQL can be determined as the verification result of the target SQL.

[0070] In the embodiment of the present invention, by sequentially executing the test data import SQL and verification SQL corresponding to the target SQL, the target SQL is verified after the operation performed by the target SQL on the target database is actually executed to obtain a verification result.

[0071] The structured query language verification method provided by an embodiment of the present invention includes: extracting a target structured query language SQL in a current code, determining a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL; determining a verification item for the target SQL according to the target test case; when the verification item is an SQL-type, determining a verification SQL and a test data import SQL corresponding to the target SQL according to the verification item; and executing the verification SQL after executing the test data import SQL to obtain a verification result of the target SQL. The above technical scheme can firstly quickly determine the target SQL to be verified in the current code according to the keywords of the operation-type SQL and the query-type SQL, so as to realize the rapid determination of the target SQL. It can also determine the target test case corresponding to the target SQL in the test case library according to the operation type of the target SQL, so as to realize the determination of the target test case required to verify the target SQL. Then, the verification items of the target SQL can be determined according to the target test case corresponding to the target SQL. For the SQL-type verification items, the verification SQL and the test data import SQL corresponding to the target SQL can be determined according to the verification items, so as to provide a code basis for the verification of the target SQL. Then, the test data import SQL and the verification SQL corresponding to the target SQL can be executed in sequence, and the verification of the target SQL can be realized after the operation of the target SQL on the target database is actually executed, so as to obtain the verification result of the target SQL and realize the automatic verification of the target SQL.

[0072] Figure 2 This is a flow chart of another structured query language verification method provided by an embodiment of the present invention. This embodiment is specific based on the above embodiment. Figure 2 As shown, in this embodiment, the method may further include:

[0073] Step 210: extract the target structured query language SQL from the current code.

[0074] In one implementation, step 210 may specifically include:

[0075] By scanning the current code, determine whether the current code contains the keywords of the operation-class SQL and / or the query-class SQL; when it is determined that the current code contains the keywords, disassemble and analyze the code fragment corresponding to the keywords to obtain the SQL fragment corresponding to the code fragment; determine the parameter annotation of the parameter passing part in the SQL fragment, and splice the SQL fragment and the parameter annotation based on SQL grammar rules to obtain the target SQL.

[0076] The keywords of operation-type SQL include INSERT, UPDATE, CREATE, and DELETE, and the keywords of query-type SQL include SELECT.

[0077] Specifically, you can first scan the current code to determine whether the scan result of the current code contains keywords such as INSERT, UPDATE, CREATE, DELETE, and SELECT. If it is determined that the current code contains any keyword, you can determine the code snippet corresponding to the keyword. Specifically, you can determine the complete statement corresponding to the keyword as the code snippet corresponding to the keyword. Then you can disassemble and analyze the code snippet corresponding to the keyword, convert the code logic of the code snippet into an SQL snippet, and obtain the SQL snippet corresponding to the code snippet. You can also determine the parameter annotation of the parameter passing part in the SQL snippet, and splice the SQL snippet and parameter annotation based on the SQL grammar rules to obtain the target SQL.

[0078] In one implementation, when extracting the target SQL in the current code, it also includes:

[0079] Determine the target database corresponding to the target SQL.

[0080] When converting the code logic of the code snippet into an SQL snippet, the database corresponding to the SQL snippet may also be determined, and the database is the target database corresponding to the target SQL.

[0081] For example, the current code scans insert, and the code snippet corresponding to insert is String sql = String.format("insert into %s.%s values ​​%s from %s.%s" where taskid = %s, schemaName, tableName, columns, schemaName, imTableName). The code logic of the code snippet is converted into an SQL snippet, and the specific parameter values ​​of the schemaName, tableName, columns, schemaName, and imTableName parameters and the database connection information corresponding to the SQL snippet are supplemented by parsing the code context logic. By splicing the above contents, the target SQL can be obtained: insert into gccm.gccm_trans_log select status fromgccm.trans_detail_log where taskid = 'parameter value'.

[0082] In actual applications, if the scan result of the current code does not contain keywords such as INSERT, UPDATE, CREATE, DELETE, and SELECT, a response indicating that the current code has no SQL changes can be generated and sent to the tester's terminal device.

[0083] In the embodiment of the present invention, it is possible to quickly determine the target SQL to be verified in the current code.

[0084] Step 220: Determine the target test case corresponding to the target SQL.

[0085] In one implementation, step 220 may specifically include:

[0086] Determine the operation type of the target SQL; and determine the target test case corresponding to the target SQL in a test case library according to the operation type of the target SQL.

[0087] The test case library includes various types of SQL verification projects, and testers can supplement or rewrite test cases based on database specification requirements and SQL features, and continuously improve the test case library so that the test case library can cover more accurate and comprehensive verification scenarios for SQL verification. When SQL needs to be verified, the corresponding test cases can be extracted from the test case library according to the operation type of the SQL to be verified. When the target SQL needs to be verified, the target test case corresponding to the target SQL can be extracted from the test case library according to the operation type of the target SQL.

[0088] Specifically, first, the operation type of the target SQL can be determined. The target SQL includes operation class SQL and query class SQL. The operation types of operation class SQL include adding class, updating class, creating class and deleting class. The operation types of query class SQL include query class. Therefore, it can be determined that the operation type of the target SQL is adding class, updating class, creating class, deleting class or query class. Then, the corresponding type of test cases can be extracted from the test case library, and the extracted test cases can be determined as the target test cases corresponding to the target SQL.

[0089] In the embodiment of the present invention, a target test case required for verifying the target SQL is determined.

[0090] Step 230: Determine the verification items of the target SQL according to the target test case.

[0091] In one implementation, step 230 may specifically include:

[0092] The case description of the target test case is determined as the verification item of the target SQL.

[0093] As described in the previous embodiment 1, the test case includes description information for the test items, and the verification items can be determined based on the description information. For example, the test case corresponding to the creation SQL may include: 1) checking whether the table has indexes, primary keys, and partitions; 2) whether the number of fields is too many. The test case corresponding to the update SQL may include: 1) checking whether the updated data in the SQL corresponding data table is correct and whether the update conditions follow the index; 2) checking whether the query conditions of the SQL follow the index. The test case corresponding to the deletion SQL may include: 1) checking whether there is a deletion condition to avoid the erroneous operation of deleting the entire table; 2) checking whether the deletion condition is based on the primary key or index to avoid performance risks caused by deletion. The test case corresponding to the query SQL may include: 1) checking whether the query conditions of the SQL follow the index, and 2) checking whether there is implicit type conversion.

[0094] Specifically, after determining the target test case corresponding to the target SQL, the verification items of the target SQL can be determined according to the description information of the test items of the target test case corresponding to the target SQL. For example, it can be determined that the verification items of the update SQL include whether the update data is correct, whether the update condition is indexed, and whether the query condition is indexed.

[0095] In the embodiment of the present invention, the verification items of the target SQL are determined according to the target test cases corresponding to the target SQL.

[0096] Step 240: When the verification project is of SQL type, the verification SQL and the test data import SQL corresponding to the target SQL are determined according to the verification project, and the verification SQL is executed after the test data import SQL is executed to obtain the verification result of the target SQL.

[0097] Specifically, for SQL-type verification items, you can first determine the verification SQL required to verify the target SQL for the verification item. Specifically, you can determine the corresponding verification SQL based on the operation type of the target SQL. For example, if the operation type of the target SQL is deletion type, you can determine the verification SQL as the query SQL for querying deleted data to verify whether the query is empty after deleting the data.

[0098] A test data import SQL for actually performing an operation corresponding to the target SQL on the target database may also be determined. Specifically, the test data import SQL corresponding to the target SQL may be determined based on the target SQL and the operation of the target SQL on the target database. For example, when the operation of the target SQL on the target database is to delete data, the test data import SQL corresponding to the target SQL may be determined to be the target SQL and the data actually to be deleted.

[0099] For example, the target SQL: insert into gccm.gccm_trans_log select status fromgccm.trans_detail_log where taskid='parameter value' corresponds to the verification SQL: select statusfrom gccm.gccm_trans_log where status=(select status from gccm.trans_detail_log where taskid='1112'), and the corresponding test data import SQL is: insert into trans_detail_log(status,taskid)values('1','1112').

[0100] In one implementation, executing the verification SQL after executing the test data import SQL to obtain the verification result of the target SQL includes:

[0101] The test data import SQL and the verification SQL are executed in sequence based on the target database to obtain a verification result of the target SQL.

[0102] After determining the verification SQL and test data import SQL corresponding to the target SQL, the test data import SQL and verification SQL can be executed in sequence based on the target database. By executing the test data import SQL corresponding to the target SQL based on the target database, the operations that the target SQL needs to perform on the target database can be actually executed. Executing the verification SQL can verify the execution result of the test data import SQL, and then the execution result of the test data import SQL can be determined as the verification result of the target SQL.

[0103] In an embodiment of the present invention, after determining the verification SQL and the test data import SQL corresponding to the SQL class verification project of the target SQL, the test data import SQL and the verification SQL corresponding to the target SQL are executed in sequence, and the target SQL is verified after the operation performed by the target SQL on the target database is actually executed to obtain the verification result of the SQL class verification project of the target SQL.

[0104] Step 250: When the verification item is a non-SQL type, determine the verification result of the target SQL by scanning the target SQL.

[0105] Specifically, for non-SQL verification items, the verification result can be determined without executing SQL, so the verification result corresponding to the verification item can be determined by referring to the verification item scanning target SQL.

[0106] In the embodiment of the present invention, the verification result of the non-SQL verification item of the target SQL is determined.

[0107] In actual applications, after determining the verification results of each verification item of the target SQL, a verification report of the target SQL can be generated. The verification report can include the target SQL, test data import SQL, verification points, verification SQL and verification results. The verification report can also be sent to the tester's terminal device.

[0108] The structured query language verification method provided by an embodiment of the present invention includes: extracting a target structured query language SQL in a current code; determining a target test case corresponding to the target SQL; determining a verification item of the target SQL according to the target test case; when the verification item is a SQL type, determining a verification SQL and a test data import SQL corresponding to the target SQL according to the verification item, executing the verification SQL after executing the test data import SQL, and obtaining a verification result of the target SQL; when the verification item is a non-SQL type, determining the verification result of the target SQL by scanning the target SQL. The above technical scheme can firstly quickly determine the target SQL to be verified in the current code according to the keywords of the operation-class SQL and the query-class SQL, so as to realize the rapid determination of the target SQL. It can also determine the target test case corresponding to the target SQL in the test case library according to the operation type of the target SQL, so as to realize the determination of the target test case required to verify the target SQL. Then, the verification project of the target SQL can be determined according to the target test case corresponding to the target SQL. For the SQL-type verification project, the verification SQL and the test data import SQL corresponding to the target SQL can be determined according to the verification project, so as to provide a code basis for the verification of the target SQL. Then, the test data import SQL and the verification SQL corresponding to the target SQL can be executed in sequence, and the verification of the target SQL can be realized after the operation of the target SQL on the target database is actually executed, so as to obtain the verification result of the SQL-type verification project of the target SQL. For the non-SQL-type verification project, the verification result can be determined by scanning the target SQL with reference to the verification project, so as to obtain the verification result of the non-SQL-type verification project of the target SQL. The tester only needs to configure the connection between the target SQL and the curtain database to start the verification, so as to realize the automatic verification of the target SQL.

[0109] In addition, developers can start verification after submitting the code, without relying on version installation in the regular process, so that testing work can be carried out in advance, and problems can be discovered and fixed early, which greatly reduces the quality risks in the R&D process and improves R&D efficiency and product quality.

[0110] Figure 3A schematic diagram of a structured query language verification device provided by an embodiment of the present invention is provided. The device can be used to verify the target SQL in the code to improve the verification efficiency. The device can be implemented by software and / or hardware and is generally integrated in an electronic device, such as a computer device.

[0111] like Figure 3 As shown, the device comprises:

[0112] The extraction module 310 is used to extract the target structured query language SQL from the current code and determine the target test case corresponding to the target SQL, wherein the target SQL includes operation-type SQL and / or query-type SQL;

[0113] A first determination module 320, configured to determine a verification item of the target SQL according to the target test case;

[0114] The second determination module 330 is used to determine the verification SQL and the test data import SQL corresponding to the target SQL according to the verification project when the verification project is of SQL type;

[0115] The execution module 340 is used to execute the verification SQL after executing the test data import SQL to obtain the verification result of the target SQL.

[0116] The structured query language verification device provided in this embodiment extracts a target structured query language SQL in the current code, determines a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL; determines a verification item for the target SQL according to the target test case; when the verification item is an SQL-type, determines a verification SQL and a test data import SQL corresponding to the target SQL according to the verification item; and executes the verification SQL after executing the test data import SQL to obtain a verification result of the target SQL. The above technical scheme can firstly quickly determine the target SQL to be verified in the current code according to the keywords of the operation-type SQL and the query-type SQL, so as to realize the rapid determination of the target SQL. It can also determine the target test case corresponding to the target SQL in the test case library according to the operation type of the target SQL, so as to realize the determination of the target test case required to verify the target SQL. Then, the verification items of the target SQL can be determined according to the target test case corresponding to the target SQL. For the SQL-type verification items, the verification SQL and the test data import SQL corresponding to the target SQL can be determined according to the verification items, so as to provide a code basis for the verification of the target SQL. Then, the test data import SQL and the verification SQL corresponding to the target SQL can be executed in sequence, and the verification of the target SQL can be realized after the operation of the target SQL on the target database is actually executed, so as to obtain the verification result of the target SQL and realize the automatic verification of the target SQL.

[0117] Based on the above embodiment, the extraction module 310 is specifically used for:

[0118] By scanning the current code, determine whether the current code contains the keywords of the operation-class SQL and / or the query-class SQL; when it is determined that the current code contains the keywords, disassemble and analyze the code fragment corresponding to the keywords to obtain the SQL fragment corresponding to the code fragment; determine the parameter annotation of the parameter passing part in the SQL fragment, splice the SQL fragment and the parameter annotation based on SQL grammar rules to obtain the target SQL; determine the operation type of the target SQL; and determine the target test case corresponding to the target SQL in the test case library according to the operation type of the target SQL.

[0119] Based on the above embodiment, the first determining module 320 is specifically configured to:

[0120] The case description of the target test case is determined as the verification item of the target SQL.

[0121] Based on the above embodiment, the extraction module 310 is further used for:

[0122] When extracting the target SQL in the current code, a target database corresponding to the target SQL is determined.

[0123] Based on the above embodiment, the execution module 340 is specifically used to:

[0124] The test data import SQL and the verification SQL are executed in sequence based on the target database to obtain a verification result of the target SQL.

[0125] Based on the above embodiment, the second determining module 330 is further configured to:

[0126] When the verification item is of non-SQL type, the verification result of the target SQL is determined by scanning the target SQL.

[0127] The structured query language verification device provided in the embodiment of the present invention can execute the structured query language verification method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the structured query language verification method.

[0128] It is worth noting that in the embodiment of the above-mentioned structured query language verification device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0129] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 4 A block diagram of an exemplary electronic device 4 suitable for implementing embodiments of the present invention is shown. Figure 4 The electronic device 4 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0130] like Figure 4 As shown, the electronic device 4 is in the form of a general purpose computing electronic device. The components of the electronic device 4 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).

[0131] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0132] The electronic device 4 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 4, including volatile and non-volatile media, removable and non-removable media.

[0133] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 4 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0134] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0135] The electronic device 4 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the electronic device 4, and / or any device that enables the electronic device 4 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 4 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. Figure 4 As shown, the network adapter 20 communicates with other modules of the electronic device 4 via the bus 18. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 4, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0136] The processing unit 16 executes various functional applications and page displays by running the program stored in the system memory 28, for example, implementing the structured query language verification method provided in the embodiment of the present invention, the method comprising:

[0137] Extracting a target structured query language SQL from the current code, and determining a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL;

[0138] Determine the verification items of the target SQL according to the target test case;

[0139] When the verification item is of SQL type, determining the verification SQL and the test data import SQL corresponding to the target SQL according to the verification item;

[0140] After executing the test data import SQL, the verification SQL is executed to obtain the verification result of the target SQL.

[0141] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the structured query language verification method provided by any embodiment of the present invention.

[0142] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the verification method of the structured query language provided in the embodiment of the present invention is implemented, for example, and the method includes:

[0143] Extract target SQL in the current code based on pre-set keywords;

[0144] Extracting a target structured query language SQL from the current code, and determining a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL;

[0145] Determine the verification items of the target SQL according to the target test case;

[0146] When the verification item is of SQL type, determining the verification SQL and the test data import SQL corresponding to the target SQL according to the verification item;

[0147] After executing the test data import SQL, the verification SQL is executed to obtain the verification result of the target SQL.

[0148] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0149] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0150] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0151] Computer program code for performing the operations of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0152] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0153] In addition, the acquisition, storage, use, and processing of data in the technical solution of the present invention are in compliance with the relevant provisions of national laws and regulations.

[0154] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A structured query language verification method, characterized in that: include: Extracting a target structured query language SQL from the current code, and determining a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL; Determine the verification items of the target SQL according to the target test case; When the verification item is of SQL type, determining the verification SQL and the test data import SQL corresponding to the target SQL according to the verification item; After executing the test data import SQL, the verification SQL is executed to obtain the verification result of the target SQL.

2. The structured query language verification method according to claim 1, characterized in that: Extract the target SQL in the current code, including: By scanning the current code, determining whether the current code contains keywords of the operation-type SQL and / or the query-type SQL; When it is determined that the current code contains the keyword, the code fragment corresponding to the keyword is disassembled and analyzed to obtain an SQL fragment corresponding to the code fragment; Determine the parameter annotation of the parameter passing part in the SQL fragment, and splice the SQL fragment and the parameter annotation based on SQL grammar rules to obtain the target SQL.

3. The structured query language verification method according to claim 1, characterized in that: Determine the target test case corresponding to the target SQL, including: Determine the operation type of the target SQL; The target test case corresponding to the target SQL is determined in a test case library according to the operation type of the target SQL.

4. The structured query language verification method according to claim 3, characterized in that: Determining the verification items of the target SQL according to the target test case includes: The case description of the target test case is determined as the verification item of the target SQL.

5. The structured query language verification method according to claim 1, characterized in that: When extracting the target SQL in the current code, it also includes: Determine the target database corresponding to the target SQL; Accordingly, after executing the test data import SQL, executing the verification SQL to obtain the verification result of the target SQL includes: The test data import SQL and the verification SQL are executed in sequence based on the target database to obtain a verification result of the target SQL.

6. The structured query language verification method according to claim 1, characterized in that: After determining the verification items of the target SQL according to the target test case, the method further includes: When the verification item is of non-SQL type, the verification result of the target SQL is determined by scanning the target SQL.

7. A structured query language verification device, characterized in that: include: An extraction module is used to extract a target structured query language SQL from the current code and determine a target test case corresponding to the target SQL, wherein the target SQL includes an operation-type SQL and / or a query-type SQL; A first determination module, used to determine the verification items of the target SQL according to the target test case; A second determination module is used to determine the verification SQL and the test data import SQL corresponding to the target SQL according to the verification project when the verification project is of SQL type; The execution module is used to execute the verification SQL after executing the test data import SQL to obtain the verification result of the target SQL.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the structured query language verification method as described in any one of claims 1-6.

9. A storage medium containing computer executable instructions, characterized in that: When the computer executable instructions are executed by a computer processor, they are used to perform the structured query language verification method as claimed in any one of claims 1 to 6.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the structured query language verification method according to any one of claims 1 to 6.