Quality inspection methods and apparatus
By determining the quality level by obtaining the target inspection package and the rule weight ratio, the problem of low flexibility and efficiency of SQL quality inspection is solved, and efficient inspection that can flexibly adapt to user needs is realized.
Patent Information
- Application Number
- CN202410962939.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2044-07-17
AI Technical Summary
In existing technologies, the structured query language (SQL) quality inspection has low flexibility and efficiency, cannot adapt to changes in user needs, and requires frequent hard-coded adjustments to the program.
By acquiring the target inspection package, which contains target inspection rules, the target database is inspected based on the package. The quality level is determined by using the weight ratio of the inspection rules and the initial quality score, avoiding hard coding and flexibly adapting to changes in user needs.
It improves the efficiency and flexibility of SQL quality checks, accurately checks the quality level of Structured Query Language text, and adapts to new user needs without hard-coding.
Smart Images

Figure CN118779348B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a quality inspection method and apparatus. Background Technology
[0002] Currently, in order to improve program quality, the Structured Query Language (SQL) written during data development needs to be quality checked. In related technologies, SQL quality checks are performed by hard-coding the program based on user requirements. However, when user requirements change, the program needs to be re-hard-coded, resulting in poor flexibility and scalability of SQL quality checks, and low efficiency of SQL quality checks. Summary of the Invention
[0003] This disclosure provides a quality inspection method and apparatus to at least partially solve one of the technical problems in the related art. The technical solution of this disclosure is as follows:
[0004] According to a first aspect of the present disclosure, a quality inspection method is provided, comprising: acquiring a target inspection package in an inspection procedure; wherein the target inspection procedure includes a target inspection rule method, the target inspection rule method including at least one target inspection rule, the target inspection rule being used to indicate restricted structured query language text; inspecting structured query language text to be inspected in a target database based on the target inspection package to obtain a first inspection result, wherein the first inspection result is used to indicate a first inspection rule associated with unqualified structured query language text, the unqualified structured query language text being used to indicate structured query language text in the structured query language text to be inspected that does not satisfy at least one of the target inspection rules; determining an inspection rule weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rules; and determining a quality level of the structured query language text to be inspected based on the inspection rule weight ratio and an initial quality score of the structured query language text to be inspected.
[0005] According to a second aspect of the present disclosure, a quality inspection apparatus is provided, comprising: a first acquisition module, configured to acquire a target inspection package in an inspection procedure; wherein the target inspection procedure includes a target inspection rule method, the target inspection rule method including at least one target inspection rule, the target inspection rule being used to indicate restricted structured query language text; an inspection module, configured to inspect structured query language text to be inspected in a target database based on the target inspection package to obtain a first inspection result, wherein the first inspection result is used to indicate a first inspection rule associated with unqualified structured query language text, the unqualified structured query language text being used to indicate structured query language text in the structured query language text to be inspected that does not satisfy at least one of the target inspection rules; a first determination module, configured to determine the inspection rule weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rules; and a second determination module, configured to determine the quality level of the structured query language text to be inspected based on the inspection rule weight ratio and the initial quality score of the structured query language text to be inspected.
[0006] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the quality inspection method as described in the first aspect of the present disclosure.
[0007] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the quality inspection method as described in the first aspect of the present disclosure.
[0008] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising: a computer program that, when executed by a processor, implements the quality inspection method as described in the first aspect of the present disclosure.
[0009] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0010] In this technical solution, a target inspection package is obtained from the inspection procedure. The target inspection package includes a target inspection rule method, which includes at least one target inspection rule. The target inspection rule indicates the restricted use of structured query language text. Based on the target inspection package, the structured query language text to be inspected in the target database is inspected to obtain a first inspection result. The first inspection result indicates the first inspection rule associated with unqualified structured query language text, and the unqualified structured query language text indicates structured query language text that does not satisfy at least one target inspection rule. The inspection rule weight ratio of the first inspection rule is determined based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rules. The quality level of the structured query language text to be inspected is determined based on the inspection rule weight ratio and the initial quality score of the structured query language text. Therefore, by defining a target inspection package, not only are user needs met, but also the target inspection rule method can be modified to adapt to changes in user needs. This approach avoids hard-coding in the program, improving the efficiency and flexibility of structured query language (ML) text verification. Specifically, when determining the weight of the first verification rule, it is based on the weight of the configured target verification rules. Different target verification rules have different weights, significantly distinguishing the target verification rules that have a significant impact on the quality of the ML text, thus better meeting user needs. Furthermore, before uploading the packaged target verification package to the verification program, an initial verification package is obtained from the verification program. This initial package is debugged and then uploaded as the target verification package. Therefore, when performing quality verification on the ML text to be verified, it is only necessary to verify the ML text in the target database based on the target verification package. Without hard-coding the program, the verification rules that the ML text does not meet can be accurately obtained from the target verification rules, achieving accurate quality level verification and further improving the flexibility of ML text quality verification.
[0011] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0012] The above and / or additional aspects and advantages of this disclosure will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, in which:
[0013] Figure 1This is a schematic flowchart of the quality inspection method shown in the first embodiment of this disclosure;
[0014] Figure 2 This is a schematic flowchart of the quality inspection method shown in the second embodiment of this disclosure;
[0015] Figure 3 This is a schematic flowchart of the quality inspection method shown in the third embodiment of this disclosure;
[0016] Figure 4 This is a flowchart illustrating the quality inspection method shown in the fourth embodiment of this disclosure;
[0017] Figure 5 This is a schematic diagram of the quality inspection device shown in the fifth embodiment of this disclosure;
[0018] Figure 6 This is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0020] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0021] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the technical solution disclosed herein are all carried out with the consent of the user, and all comply with the provisions of relevant laws and regulations, and do not violate public order and good morals.
[0022] Currently, the method of verifying structured query language text through hard-coding in the relevant technology has the following problems:
[0023] 1. When user needs change, the same program cannot meet the new requirements. This is because the structured query language text restricted by the user has changed, and the validation rules within the same program cannot adapt to the new requirements. This necessitates recoding and releasing a new program, leading to a rigid development process.
[0024] 2. Even the needs of the same user may have different focuses, and some validation rules are important standards for evaluating the quality of structured query language text.
[0025] To address the aforementioned issues, this disclosure proposes a quality inspection method and apparatus.
[0026] The quality inspection method and apparatus of this disclosure are described below with reference to the accompanying drawings.
[0027] Figure 1 This is a schematic flowchart of a quality inspection method provided in an embodiment of the present disclosure.
[0028] like Figure 1 As shown, this quality inspection method includes the following steps:
[0029] Step 101: Obtain the target inspection package in the inspection procedure.
[0030] The target validation procedure includes a target validation rule method, which includes at least one target validation rule. The target validation rule is used to indicate the restricted use of structured query language text.
[0031] In order to ensure that the target inspection rules in the acquired target inspection package meet the user's needs, as a possible implementation method, the target inspection rules in the target inspection package are determined based on the user's needs.
[0032] For example, if a user's requirement for Structured Query Language (SCL) text is to restrict the use of the Drop statement, the inclusion of a NOT clause in the WHERE clause, and the restriction of the use of the UNION statement, then the target validation rule would be to restrict the use of the Drop statement, the inclusion of a NOT clause in the WHERE clause, and the restriction of the use of the UNION statement.
[0033] In addition, it should be noted that different users have different needs for structured query language text, and therefore the number of target validation rules and the number of target validation rules also differ.
[0034] Step 102: Based on the target verification package, the structured query language text to be verified in the target database is verified to obtain the first verification result.
[0035] The first test result is used to indicate the first test rule associated with the unqualified structured query language text, and the unqualified structured query language text is used to indicate the structured query language text that does not satisfy at least one target test rule in the structured query language text to be tested.
[0036] As an example, the structured query language text to be tested includes multiple structured query statements, wherein at least one of the multiple structured query statements is considered as the structured query language text in the structured query language text to be tested.
[0037] In order to accurately identify the structured query language text to be tested that does not meet the target test rules, one possible approach is to traverse the structured query language text to be tested to obtain structured query language text that does not meet at least one target test rule, i.e., obtain unqualified structured query language text. Then, according to the first test rule associated with the unqualified structured query language text, the first test result is obtained.
[0038] As an example, when the structured query language text to be tested includes both structured query language text that satisfies all target test rules (or, if there are multiple target test rules, one of the target test rules is satisfied and is unrelated to the other target test rules) and structured query language text that does not satisfy at least one target test rule, the at least one target test rule that the structured query language text does not satisfy is taken as the first test rule.
[0039] For example, if the structured query language text to be tested includes structured query language text that uses the Drop statement, then the structured query language text that uses the Drop statement is an invalid structured query language text, and the target testing rule associated with this invalid structured query language text (restricting the use of the Drop statement) is the first testing rule.
[0040] Step 103: Determine the weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule.
[0041] To clearly distinguish the target validation rules that have a significant impact on the quality of structured query language text and better meet user needs, as an example, we configure the weights of the target validation rules.
[0042] For example, when users restrict the use of Structured Query Language (SCL) text, restricting the use of the Drop statement is a target test rule that significantly affects the quality of the SCL text. However, including NOT clauses in the WHERE clause and restricting the use of UNION statements are not target test rules that significantly affect the quality of the SCL text. Therefore, when configuring weights for restricting the use of the Drop statement, including NOT clauses in the WHERE clause, and restricting the use of UNION statements, the weight for restricting the use of the Drop statement can be configured as 2, and the weights for including NOT clauses in the WHERE clause and restricting the use of UNION statements can both be configured as 1. Among them, the target validation rule for unqualified structured query language text association (restricting the use of the Drop statement) is the first validation rule, and its weight is 2. The target validation rules include restricting the use of the Drop statement, including the NOT clause in the WHERE clause, and restricting the use of the UNION statement. The sum of the weights of the target validation rules is the sum of the weight of restricting the use of the Drop statement (2), the weight of including the NOT clause in the WHERE clause (1), and the weight of restricting the use of the UNION statement (1), which is 4. Therefore, the weight ratio of the first validation rule is 1 / 2.
[0043] Step 104: Determine the quality level of the structured query language text to be tested based on the weighting of the testing rules and the initial quality score of the text.
[0044] It's important to understand that since the validation of structured query language (ML) text in the target database is based on target validation packages, different target validation packages include different target validation rules, each catering to different user needs. Therefore, when user needs change, the target validation rules can be updated to match the new requirements without hard-coding them directly in the validation program. This flexibly meets users' needs for ML text quality validation, improving the efficiency and flexibility of ML text quality validation.
[0045] As an example, the target quality score of the structured query language text to be tested is determined based on the weighting of the testing rules and the initial quality score of the text. Based on the target quality score, the corresponding quality level is determined, which includes: excellent, good, poor, and unqualified. The initial quality score is preset based on historical experience.
[0046] To improve the objectivity of quality testing of the structured query language texts to be tested, as an example, different structured query language texts to be tested have the same initial quality score.
[0047] In summary, this method involves obtaining the target inspection package within the inspection program; inspecting the structured query language text to be inspected in the target database based on the target inspection package to obtain a first inspection result; determining the weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rules; and determining the quality level of the structured query language text to be inspected based on the weight ratio of the inspection rules and the initial quality score of the structured query language text. Thus, the target inspection package is pre-configured in the inspection program, and the target inspection rules within the target inspection package are used to inspect the structured query language text to obtain an inspection result. Based on the weight of the inspection rules associated with the inspection result and the initial quality score of the structured query language text to be inspected, a deduction is made from the quality level of the structured query language text to be inspected. By defining the target inspection package, not only are user needs met, but the method also adapts to changing user needs by modifying the target inspection rules included in the target inspection rule method, avoiding hard coding and improving the efficiency and flexibility of structured query language text quality inspection.
[0048] To clearly illustrate how the above embodiments use the target inspection package to inspect the structured query language text in the target database to obtain the first inspection result, this disclosure proposes another quality inspection method.
[0049] Figure 2 This is a flowchart illustrating the quality inspection method shown in the second embodiment of this disclosure.
[0050] like Figure 2 As shown, this quality inspection method includes the following steps:
[0051] Step 201: Obtain the target inspection package in the inspection procedure.
[0052] Step 202: In response to finding the current class loader, the current class loader is invoked, and the target verification rule method in the target verification package is loaded.
[0053] Among them, the target inspection rule method is the method in the target inspection interface of the target inspection program.
[0054] As an example, find the current class loader that matches the class loading request, and when the current class loader is found, invoke the current class loader and load the target validation rule method.
[0055] As another example, if no current class loader is found that matches the class loading request, the class loading request is delegated to the parent class loader, which then loads the target validation rule method.
[0056] Step 203: Based on the target verification interface, obtain the type of the target database and the structured query language text to be verified in the target database.
[0057] To effectively obtain the structured query language text to be tested, one possible approach is to define target testing rules in the target testing interface to determine the structured query language text to be tested in the target database.
[0058] As an example, the target validation rule method defined in the target interface defines two input parameters: one is the structured query language text to be validated, and the other is the target database extension information. The target database extension information includes the target database type, database connection information, and other details.
[0059] Step 204: Based on the type of the target database, call the corresponding Structured Query Language parser. Use the Structured Query Language parser to perform syntactic parsing on the Structured Query Language text to be tested, so as to obtain the abstract syntax tree corresponding to the Structured Query Language text to be tested.
[0060] To obtain the complete abstract syntax tree (AST) of the structured query language (ML) text to be tested, as an example, each structured query statement in the ML text is traversed sequentially. Then, a ML parser is used to perform syntax parsing on each structured query statement in the ML text to obtain the corresponding AST. The ML parser used will differ depending on the type of the target database.
[0061] Step 205: Using an abstract syntax tree and target validation rules, the structured query language text to be validated is tested to obtain unqualified structured query language text.
[0062] Step 206: Obtain the first inspection rule associated with the unqualified structured query language text from the target inspection rules, and use the first inspection rule as the first inspection result.
[0063] It is important to understand that the focus of quality inspection of structured query language text is whether the structured query language text meets the target inspection rules, and the quality level of the structured query language text is determined based on the target inspection rules that the structured query language text does not meet.
[0064] Therefore, as an example, after using an abstract syntax tree and target validation rules to validate the structured query language text to be validated, and obtaining unqualified structured query language text, the first validation rule associated with the unqualified structured query language text can be used as the first validation result, so that the quality of the structured query language text can be validated in a targeted manner based on the first validation result.
[0065] Step 207: Determine the weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule.
[0066] Step 208: Determine the quality level of the structured query language text to be tested based on the weighting of the testing rules and the initial quality score of the text.
[0067] It should be noted that the execution process of steps 201 and 205 to 208 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.
[0068] In summary, in response to finding the current class loader, the current class loader is invoked, and the target validation rule method is loaded. This target validation rule method is a method within the target validation interface of the target validation program. Based on the target validation interface, the type of the target database and the structured query language text to be validated within the target database are obtained. According to the type of the target database, the corresponding structured query language parser is invoked. The structured query language parser is used to perform syntax parsing on the structured query language text to be validated, obtaining the abstract syntax tree corresponding to the structured query language text to be validated. Finally, using the abstract syntax tree and the target validation rules, the structured query language text to be validated is... The process involves performing an inspection to identify non-compliant structured query language text. From the target inspection rules, a first inspection rule associated with the non-compliant structured query language text is obtained, and this first inspection rule is used as the first inspection result. Thus, when obtaining the first inspection result, the abstract syntax tree and the target inspection rules are first used to inspect the structured query language text to be inspected, identifying non-compliant text. The first inspection result is then obtained through the first inspection rule associated with the non-compliant text. This approach focuses on whether the structured query language text meets the target inspection rules, thereby enabling targeted quality inspection of the structured query language text.
[0069] To clearly illustrate how the quality level of the structured query language text to be tested is determined based on the weighting of the testing rules and the initial quality score of the text to be tested in the above embodiments, this disclosure proposes another quality testing method.
[0070] Figure 3 This is a flowchart illustrating the quality inspection method shown in the third embodiment of this disclosure.
[0071] like Figure 3 As shown, this quality inspection method includes the following steps:
[0072] Step 301: Obtain the target inspection package in the inspection procedure.
[0073] Step 302: Based on the target verification package, the structured query language text to be verified in the target database is verified to obtain the first verification result.
[0074] Step 303: Determine the weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule.
[0075] Step 304: Based on the weighting of the testing rules, deduct points from the initial quality score of the structured query language text to be tested to obtain the target quality score of the structured query language text to be tested.
[0076] For example, if the initial quality score of the structured query language text to be tested is 100, and the weight of the first test rule is 1 / 2, then the target quality score of the structured query language text to be tested is 100 - 100 * 1 / 2 = 50.
[0077] Step 305: Determine the quality level of the structured query language text to be tested based on the target quality score.
[0078] To more intuitively determine the quality of structured query language text, as an example, based on the target quality score, the target score interval is determined from multiple candidate score intervals. Then, based on the quality level corresponding to the target score interval, the quality level of the structured query language text to be tested is determined.
[0079] It should be noted that each candidate score range has a corresponding quality level.
[0080] For example, the quality score and quality level comparison table is shown in Table 1. Suppose the target quality score of the structured query language text to be tested is 50. According to the quality level comparison table, the candidate score interval where the target quality score is located is the third candidate score interval in the quality level comparison table. Then the quality level of the structured query language text to be tested can be expressed as "poor".
[0081] Table 1. Comparison of Quality Score and Quality Grade
[0082] Candidate score range Quality grade 80<Target Quality Score≤100 excellent 60 < target quality score ≤ 80 good 40 < target quality score ≤ 60 inferior 0<Target quality score≤40 Unqualified
[0083] It should be noted that the execution process of steps 301 to 303 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.
[0084] In summary, by subtracting points from the initial quality score of the structured query text to be tested based on the weighting of the testing rules, a target quality score is obtained. Based on the target quality score, the quality level of the structured query text is determined, thereby determining the target quality score. From multiple candidate score ranges, the target score range is determined, and the quality level of the structured query text is determined based on the quality level corresponding to the target score range. By pre-setting multiple quality levels and accurately determining the quality level of the structured query text from these pre-set quality levels based on its target quality score, a more intuitive method for determining the quality of structured query text is achieved.
[0085] To clearly illustrate how the target inspection package is obtained before uploading the packaged target inspection package to the inspection program in the above embodiments, this disclosure proposes another quality inspection method.
[0086] Figure 4 This is a flowchart illustrating the quality inspection method shown in the fourth embodiment of this disclosure.
[0087] like Figure 4 As shown, this quality inspection method includes the following steps:
[0088] Step 401: Obtain the initial inspection program package from the inspection program.
[0089] It is important to understand that, in order to perform the test on the structured query language text in the target database based on the target test package, and to more accurately obtain the test rules that the structured query language text does not meet from the target test rules, an initial test package is obtained before uploading the packaged target test package to the test program. The initial test package is then debugged, and the debugged initial test package is uploaded to the test program as the target test package.
[0090] Therefore, to accurately obtain the initial verification package, as an example, before obtaining the initial verification package in the verification program, the following steps are taken: First, obtain the interface creation request and, based on the interface creation request, create the initial verification interface in the initial verification package to be generated. Second, determine the initial verification rules in the initial verification package to be generated based on the restricted Structured Query Language text. Third, construct the initial verification methods in the initial verification package to be generated based on the initial verification rules. Finally, package the initial verification interface and the initial verification rules to obtain the initial verification package. It should be noted that the interface creation request includes the restricted Structured Query Language text.
[0091] For example, the initial check rules in the initial check package restrict the use of the Drop statement, include a NOT clause in the WHERE clause, and restrict the use of the UNION statement.
[0092] Step 402: Obtain the Debug Structured Query Language text from the debug database.
[0093] Among them, the debug structured query language text contains debug structured query language text that does not satisfy at least one initial check rule in the initial check package, and the indication information of the associated check rule associated with the debug structured query language text that does not satisfy at least one initial check rule.
[0094] For example, there are structured query language texts that use the Drop statement in the debugging structured query language text. The structured query language texts that use the Drop statement are the debugging structured query language texts that do not meet the initial test rules (restricting the use of the Drop statement) in the initial test package. The restriction on the use of the Drop statement associated with the debugging structured query language texts that do not meet the initial test rules (restricting the use of the Drop statement) is the associated test rule.
[0095] Step 403: Use the initial verification package to verify the debugged structured query language text to obtain the second verification result.
[0096] To effectively obtain the second verification result, one possible implementation involves verifying the debug structured query language text based on the abstract syntax tree corresponding to the debug structured query language text and the initial verification rules in the initial verification package. This results in invalid debug structured query language text. Then, based on the second verification rules associated with the invalid debug structured query language text, the second verification result is determined. As an example, when the current class loader is found, it is invoked, and the initial verification method in the initial verification interface of the initial verification package is loaded. Then, based on the initial verification interface, the type of the debug database is obtained. According to the type of the debug database, the corresponding structured query language parser is invoked. The structured query language parser performs syntax parsing on the debug structured query language text to obtain the abstract syntax tree corresponding to the debug structured query language text. The abstract syntax tree and the initial verification rules are then used to verify the debug structured query language text, resulting in invalid debug structured query language text. Thus, the second verification rule associated with the invalid debug structured query language text is obtained from the initial verification rules, and this second verification rule is used as the second verification result.
[0097] The second test result is used to indicate the second test rule associated with the unqualified debug structured query language text. The unqualified debug structured query language text is used to indicate debug structured query language text that does not satisfy at least one initial test rule.
[0098] Step 404: In response to the second test result being consistent with the indication information, the initial test package is used as the target test package.
[0099] In order to accurately obtain the target inspection package, as one possible implementation, the target inspection package is determined based on the comparison result between the second inspection result and the indication information.
[0100] As an example, in response to the second inspection result being consistent with the indication information, when the initial inspection package is uploaded to the inspection program as the target inspection package, a configuration interface for setting the target inspection package is displayed, and the target inspection rule metadata information is configured on the configuration page.
[0101] In addition, it should be noted that the target validation rule metadata information includes at least one of the following: the name of the target validation rule; the weight of the target validation rule; the database type of the database to which the quality validation is applied; and optimization suggestions. The optimization suggestions are used to adjust the structured query language text that does not meet the target validation rules.
[0102] As another example, in response to the inconsistency between the second inspection result and the indication information, the initial inspection package is adjusted according to the indication information; the adjusted initial inspection package is used to inspect the debug structured query language text to obtain a third inspection result; wherein the third inspection result is used to indicate the third inspection rule associated with the unqualified debug structured query language text.
[0103] Step 405: Based on the target verification package, the structured query language text to be verified in the target database is verified to obtain the first verification result.
[0104] Step 406: Determine the weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule.
[0105] Step 407: Determine the quality level of the structured query language text to be tested based on the weighting of the testing rules and the initial quality score of the text.
[0106] It should be noted that the execution process of steps 405 to 407 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.
[0107] In summary, the process involves: obtaining an initial inspection package from the inspection procedure; obtaining debug structured query language text from the debug database; using the initial inspection package to inspect the debug structured query language text to obtain a second inspection result; and, in response to the second inspection result being consistent with the indicated information, using the initial inspection package as the target inspection package. Thus, before uploading the packaged target inspection package to the inspection procedure, the obtained initial inspection package can be debugged. By uploading the debugged initial inspection package as the target inspection package to the inspection procedure, when performing quality inspection on the structured query language text to be inspected, it is only necessary to inspect the structured query language text in the target database based on the target inspection package. Without hard-coding the program, the inspection rules that the structured query language text to be inspected does not meet can be accurately obtained from the target inspection rules, thereby obtaining the quality level of the structured query language text to be inspected. This further improves the flexibility of quality inspection of structured query language text.
[0108] Corresponding to the quality inspection method provided in the above embodiments, this disclosure also provides a quality inspection device. Since the quality inspection device provided in this disclosure corresponds to the quality inspection method provided in the above embodiments, the implementation of the quality inspection method is also applicable to the quality inspection device provided in this disclosure, and will not be described in detail in this disclosure.
[0109] Figure 5 This is a schematic diagram of the quality inspection device shown in the fifth embodiment of this disclosure.
[0110] like Figure 5 As shown, the quality inspection device 500 includes: a first acquisition module 501, an inspection module 502, a first determination module 503, and a second determination module 504.
[0111] The system comprises the following modules: a first acquisition module 501, used to acquire a target inspection package in the inspection procedure; wherein the target inspection package includes a target inspection rule method, the target inspection rule method includes at least one target inspection rule, and the target inspection rule is used to indicate the restricted structured query language text; an inspection module 502, used to inspect the structured query language text to be inspected in the target database based on the target inspection package to obtain a first inspection result, wherein the first inspection result is used to indicate the first inspection rule associated with the unqualified structured query language text, and the unqualified structured query language text is used to indicate the structured query language text in the structured query language text to be inspected that does not satisfy at least one target inspection rule; a first determination module 503, used to determine the inspection rule weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rules; and a second determination module 504, used to determine the quality level of the structured query language text to be inspected based on the inspection rule weight ratio and the initial quality score of the structured query language text to be inspected.
[0112] As one possible implementation of this disclosure, the verification module 502 is used to, in response to finding the current class loader, call the current class loader and load the target verification rule method in the target verification package; and to, based on the class object created by the target verification rule method, verify the structured query language text to be verified in the target database to obtain the first verification result returned by the target verification rule method.
[0113] As one possible implementation of this disclosure, the target verification rule method is a method in the target verification interface of the target verification program. The verification module 502 is used to obtain the type of the target database and the structured query language text to be verified in the target database based on the target verification interface; according to the type of the target database, the corresponding structured query language parser is called, and the structured query language parser is used to perform syntactic parsing on the structured query language text to be verified to obtain the abstract syntax tree corresponding to the structured query language text to be verified; the abstract syntax tree and the target verification rules are used to verify the structured query language text to be verified to obtain the unqualified structured query language text; from the target verification rules, the first verification rule associated with the unqualified structured query language text is obtained, and the first verification rule is used as the first verification result.
[0114] As one possible implementation of this disclosure, the second determining module 504 is used to deduct points from the initial quality score of the structured query language text to be tested according to the weight ratio of the testing rules, so as to obtain the target quality score of the structured query language text to be tested; and to determine the quality level of the structured query language text to be tested based on the target quality score.
[0115] As one possible implementation of this disclosure, the second determining module 504 is used to determine the target score interval where the target quality score is located from a plurality of set candidate score intervals; wherein each candidate score interval has a corresponding quality level; and the quality level of the structured query language text to be tested is determined according to the quality level corresponding to the target score interval.
[0116] As a possible implementation of this disclosure, the quality inspection device 500 further includes: an initial inspection program package module, an adjustment module, and a configuration interface module.
[0117] The initial inspection package module is used to obtain the initial inspection package in the inspection program; obtain the debugging structured query language text in the debugging database; wherein the debugging structured query language text contains debugging structured query language text that does not satisfy at least one initial inspection rule in the initial inspection package, and indication information of the associated inspection rules associated with the debugging structured query language text that does not satisfy at least one initial inspection rule; use the initial inspection package to inspect the debugging structured query language text to obtain a second inspection result; wherein the second inspection result is used to indicate the second inspection rule associated with the unqualified debugging structured query language text, and the unqualified debugging structured query language text is used to indicate the debugging structured query language text that does not satisfy at least one initial inspection rule; in response to the second inspection result being consistent with the indication information, the initial inspection package is used as the target inspection package.
[0118] As one possible implementation of this disclosure, the adjustment module is configured to, in response to a discrepancy between the second inspection result and the indication information, adjust the initial inspection package according to the indication information; use the adjusted initial inspection package to inspect the debug structured query language text to obtain a third inspection result; wherein the third inspection result is used to indicate the third inspection rule associated with the unqualified debug structured query language text; and in response to a consistency between the third inspection result and the indication information, use the adjusted initial inspection package as the target inspection package.
[0119] As one possible implementation of this disclosure, the initial verification package module is further configured to obtain an interface creation request and, based on the interface creation request, create an initial verification interface in the initial verification package to be generated; wherein the interface creation request includes restricted Structured Query Language text; determine the initial verification rules in the initial verification package to be generated based on the restricted Structured Query Language text; construct the initial verification method in the initial verification package to be generated based on the initial verification rules; and package the initial verification interface and the initial verification rules to obtain the initial verification package.
[0120] As one possible implementation of this disclosure, in response to the second inspection result being consistent with the indication information, after the initial inspection package is set as the target inspection package, the configuration interface module 507 is used to display a configuration interface for setting the target inspection package and to configure the target inspection rule metadata information on the configuration page.
[0121] The quality inspection apparatus of this embodiment acquires a target inspection package in the inspection program; based on the target inspection package, it inspects the structured query language text to be inspected in the target database to obtain a first inspection result; it determines the inspection rule weight ratio of the first inspection rule according to the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule; and it determines the quality level of the structured query language text to be inspected based on the inspection rule weight ratio and the initial quality score of the structured query language text to be inspected. Thus, before inspecting the structured query language text to be inspected, the target inspection package is configured in the inspection program. The target inspection rule includes a target inspection rule method, which includes a structure that satisfies user restrictions. The system implements target validation rules for structured query language text, and then uses these rules to validate the text to obtain validation results. Based on the weights of the validation rules associated with the validation results and the initial quality score of the text to be validated, a deduction is made from the text to determine its quality level. By using a defined target validation package, the system not only meets user needs but also adapts to changing user requirements by modifying the target validation rules. This avoids hard-coding and allows for flexible validation of structured query language text, improving both the efficiency and flexibility of quality validation.
[0122] In an exemplary embodiment, an electronic device is also proposed.
[0123] The electronic devices include:
[0124] processor;
[0125] Memory used to store processor-executable instructions;
[0126] The processor is configured to execute instructions to implement the quality inspection method as proposed in any of the foregoing embodiments.
[0127] As an example, Figure 6 This is a schematic diagram of the structure of an electronic device 600 as shown in an exemplary embodiment of this disclosure, as follows: Figure 6 As shown, the aforementioned electronic device 600 may further include:
[0128] The memory 610 and the processor 620 are connected by a bus 630, which connects the different components (including the memory 610 and the processor 620). The memory 610 stores a computer program, and when the processor 620 executes the program, it implements the quality inspection method described in the embodiments of this disclosure.
[0129] Bus 630 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0130] Electronic device 600 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by electronic device 600, including volatile and non-volatile media, removable and non-removable media.
[0131] Memory 610 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 640 and / or cache memory 650. Server 600 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 660 may be used to read and write non-removable, non-volatile magnetic media (… Figure 6 Not shown; usually referred to as a "hard drive package"). Although Figure 6Not shown, a disk drive package for reading and writing to removable non-volatile disks (e.g., "floppy disks") and an optical disk drive package for reading and writing to removable non-volatile optical disks (e.g., CD-ROMs, DVD-ROMs, or other optical media) may be provided. In these cases, each drive package may be connected to bus 630 via one or more data media interfaces. Memory 610 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.
[0132] A program / utility 680 having a set (at least one) of program modules 670 may be stored, for example, in memory 610. Such program modules 670 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 670 typically perform the functions and / or methods described in the embodiments of this disclosure.
[0133] Electronic device 600 can also communicate with one or more external devices 660 (e.g., keyboard, pointing device, display 691, etc.), and with one or more devices that enable a user to interact with electronic device 600, and / or with any device that enables electronic device 600 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 692. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 693. As shown, network adapter 693 communicates with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device driver packages, redundant processing units, external disk drive package arrays, RAID systems, tape drive packages, and data backup storage systems.
[0134] The processor 620 executes various functional applications and data processing by running programs stored in the memory 610.
[0135] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the quality inspection method of the present disclosure embodiment, and will not be repeated here.
[0136] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, which can be executed by a processor of an electronic device to perform the quality inspection method proposed in any of the above embodiments. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0137] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the quality inspection method proposed in any of the above embodiments.
[0138] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0139] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A quality inspection method characterized by comprising: Includes the following steps: Obtain the initial inspection package from the inspection procedure; Obtain debug structured query language text from the debug database; wherein the debug structured query language text includes debug structured query language text that does not satisfy at least one initial check rule in the initial check package, and indication information of the associated check rule associated with the debug structured query language text that does not satisfy at least one initial check rule; use the initial check package to check the debug structured query language text to obtain a second check result; wherein the second check result is used to indicate the second check rule associated with the unqualified debug structured query language text, and the unqualified debug structured query language text is used to indicate debug structured query language text that does not satisfy at least one initial check rule; in response to the second check result being consistent with the indication information, use the initial check package as the target check package; wherein the target check package includes a target check rule method, the target check rule method includes at least one target check rule, and the target check rule is used to indicate restricted structured query language text; Based on the target inspection package, the structured query language text to be inspected in the target database is inspected to obtain a first inspection result, wherein the first inspection result is used to indicate a first inspection rule associated with the unqualified structured query language text, and the unqualified structured query language text is used to indicate structured query language text that does not satisfy at least one of the target inspection rules in the structured query language text to be inspected. The weight ratio of the first inspection rule is determined based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule. The quality level of the structured query language text to be tested is determined based on the weighting of the testing rules and the initial quality score of the text.
2. The method according to claim 1, characterized in that, The step of using the target inspection package to inspect the structured query language text in the target database to obtain a first inspection result includes: In response to finding the current class loader, the current class loader is invoked, and the target verification rule method in the target verification package is loaded; The class object created based on the target inspection rule method is used to inspect the structured query language text to be inspected in the target database to obtain the first inspection result returned by the target inspection rule method.
3. The method according to claim 2, characterized in that, The target inspection rule method is the method in the target inspection interface of the target inspection program; The class object created based on the target verification rule method verifies the structured query language text to be verified in the target database to obtain the first verification result returned by the target verification rule method, including: Based on the target verification interface, the type of the target database is obtained, and the structured query language text to be verified in the target database is obtained; Based on the type of the target database, the corresponding structured query language parser is invoked, and the structured query language parser is used to perform syntactic parsing on the structured query language text to be tested, so as to obtain the abstract syntax tree corresponding to the structured query language text to be tested. The abstract syntax tree and the target validation rules are used to validate the structured query language text to be validated, so as to obtain the unqualified structured query language text. From the target inspection rules, obtain the first inspection rule associated with the unqualified structured query language text, and use the first inspection rule as the first inspection result.
4. The method according to claim 1, characterized in that, The step of determining the quality level of the structured query language text to be tested based on the weighting of the testing rules and the initial quality of the text to be tested includes: Based on the weighting of the test rules, the initial quality score of the structured query language text to be tested is reduced to obtain the target quality score of the structured query language text to be tested. The quality level of the structured query language text to be tested is determined based on the target quality score.
5. The method according to claim 4, characterized in that, Determining the quality level of the structured query language text to be tested based on the target quality score includes: From a set of multiple candidate score intervals, the target score interval in which the target quality score is located is determined; wherein each candidate score interval has a corresponding quality level; The quality level of the structured query language text to be tested is determined based on the quality level corresponding to the target score range.
6. The method according to claim 1, characterized in that, The method further includes: In response to the inconsistency between the second test result and the indication information, the initial test package is adjusted according to the indication information; The debug structured query language text is inspected using an adjusted initial inspection package to obtain a third inspection result; wherein the third inspection result is used to indicate the third inspection rule associated with the unqualified debug structured query language text. In response to the third test result being consistent with the indication information, the adjusted initial test package is used as the target test package.
7. The method according to claim 1, characterized in that, The acquisition of the initial inspection package in the inspection procedure includes: Obtain the interface creation request, and based on the interface creation request, create the initial verification interface in the initial verification package to be generated; wherein, the interface creation request includes restricted Structured Query Language text; Based on the restricted use of the Structured Query Language text, determine the initial verification rules in the initial verification package to be generated; Based on the initial inspection rules, construct the initial inspection method in the initial inspection package to be generated; The initial inspection interface and the initial inspection rules are packaged together to obtain the initial inspection package.
8. The method according to claim 1, characterized in that, In response to the second test result being consistent with the indication information, after setting the initial test package as the target test package, the method further includes: A configuration interface for setting up the target inspection package is displayed, and target inspection rule metadata information is configured in the configuration interface.
9. A quality inspection device, characterized in that, Includes the following steps: The first acquisition module is used to acquire the target inspection package in the inspection program; wherein, the target inspection program includes a target inspection rule method, the target inspection rule method includes at least one target inspection rule, and the target inspection rule is used to indicate the restricted use of Structured Query Language text; The inspection module is used to inspect the structured query language text to be inspected in the target database based on the target inspection package to obtain a first inspection result, wherein the first inspection result is used to indicate a first inspection rule associated with the unqualified structured query language text, and the unqualified structured query language text is used to indicate structured query language text that does not satisfy at least one of the target inspection rules in the structured query language text to be inspected. The first determining module is used to determine the weight ratio of the first inspection rule based on the ratio between the weight of the first inspection rule and the sum of the weights of the target inspection rule. The second determining module is used to determine the quality level of the structured query language text to be tested based on the weight ratio of the testing rules and the initial quality score of the structured query language text to be tested. The quality inspection device also includes: An initial inspection package module is used to obtain an initial inspection package from the inspection program; obtain debugging structured query language text from the debugging database; wherein the debugging structured query language text includes debugging structured query language text that does not satisfy at least one initial inspection rule in the initial inspection package, and indication information of the associated inspection rule associated with the debugging structured query language text that does not satisfy at least one initial inspection rule; use the initial inspection package to inspect the debugging structured query language text to obtain a second inspection result; wherein the second inspection result is used to indicate the second inspection rule associated with the unqualified debugging structured query language text, and the unqualified debugging structured query language text is used to indicate the debugging structured query language text that does not satisfy at least one initial inspection rule; in response to the second inspection result being consistent with the indication information, the initial inspection package is used as the target inspection package.
Citation Information
Patent Citations
SQL query statement performance detection method and device
CN113434430A
SQL (Structured Query Language) code quality control method and device, equipment and storage medium
CN118093623A
