Data comparison method and device, electronic equipment and storage medium
Through the data comparison method, the SQL file of the SQL label and database structure in Mybatis files in Mybatis files solves the problem of incomplete case coverage and tight testing time caused by database structure changes. Whether the database structure exists correctly.
Patent Information
- Application Number
- CN202411433314.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-01-28
AI Technical Summary
When developing a system with business logic, multiple changes in the database structure lead to incomplete use case coverage and tight test time, making it difficult to ensure that the database structure is updated as expected.
Put forward a data comparison method. By obtaining the SQL file of the MyBatis file and the database structure, formatting the SQL file, using the XML regular expression to analyze the SQL label in mybatis file, extract the type and logic SQL content, use SQL regular expression analysis analysis Logic SQL content, extract key content, and compare key content with formatting data to determine whether the SQL label exists correctly in the database structure.
It realizes whether each SQL label in the Mybatis file is quickly and accurately determined whether each section of SQL tags in the database structure exist correctly, and solve the problem of incomplete case coverage caused by the multiple changes in the database structure and tight testing time.
Smart Images

Figure CN119377087A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data comparison method, device, electronic device and storage medium. Background Art
[0002] For the development of systems with business logic and complex database structures, in one version, there may be multiple changes to the database structure by adding new logical SQL, such as adding new tables, fields, indexes, and views. Therefore, it is necessary to ensure that the database structure is updated as expected.
[0003] In related technologies, use cases can be written to verify whether the database structure adjustment and the newly added logical SQL match. However, due to the frequent changes in the database structure, there are problems such as incomplete coverage of use cases and tight testing time. Summary of the invention
[0004] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0005] To this end, the first purpose of this application is to propose a data comparison method to quickly and accurately determine whether each SQL tag in a Mybatis file exists correctly in the database structure.
[0006] The second objective of this application is to provide a data comparison device.
[0007] The third objective of the present application is to provide an electronic device.
[0008] A fourth objective of the present application is to provide a computer-readable storage medium.
[0009] A fifth object of the present application is to provide a computer program product.
[0010] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a data comparison method, including:
[0011] Get the Mybatis file corresponding to the target system and the SQL file of the database structure;
[0012] Formatting the SQL file of the database structure to obtain formatted data corresponding to the database structure;
[0013] Based on XML regular expressions, parse each SQL tag in the XML file in the Mybatis file to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag;
[0014] Parsing the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain key content included in the logical SQL content;
[0015] The key content corresponding to each SQL tag is compared with the formatted data to obtain a comparison result.
[0016] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a data comparison device, including:
[0017] The acquisition module is used to obtain the Mybatis file corresponding to the target system and the SQL file of the database structure;
[0018] A processing module, used for formatting the SQL file of the database structure to obtain formatted data corresponding to the database structure;
[0019] The first parsing module is used to parse each SQL tag in the XML file in the Mybatis file based on XML regular expressions to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag;
[0020] A second parsing module, used to parse the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain key content included in the logical SQL content;
[0021] The comparison module is used to compare the key content corresponding to each SQL tag with the formatted data to obtain a comparison result.
[0022] To achieve the above-mentioned purpose, the third aspect of the present application provides an electronic device, including:
[0023] A processor, and a memory communicatively connected to the processor;
[0024] The memory stores computer-executable instructions;
[0025] The processor executes the computer-executable instructions stored in the memory to implement the method as described in the embodiment of the first aspect.
[0026] To achieve the above-mentioned purpose, the fourth aspect embodiment of the present application proposes a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the method described in the first aspect embodiment.
[0027] To achieve the above-mentioned purpose, the fifth aspect of the present application proposes a computer program product, a computer program, which implements the method described in the first aspect when executed by a processor.
[0028] The data comparison method, device, electronic device and storage medium provided by the present application obtain the Mybatis file corresponding to the target system and the SQL file of the database structure; format the SQL file of the database structure to obtain the formatted data corresponding to the database structure; parse each SQL tag in the XML file in the Mybatis file based on the XML regular expression to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag; parse the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain the key content contained in the logical SQL content; compare the key content corresponding to each SQL tag with the formatted data to obtain the comparison result. Thus, the content of each SQL tag in the Mybatis file can be extracted based on the regular expression, and then the extracted key content can be compared with the formatted data corresponding to the SQL file of the database structure, so as to quickly and accurately determine whether each SQL tag in the Mybatis file exists correctly in the database structure.
[0029] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0031] Figure 1 A flow chart of a data comparison method provided in an embodiment of the present application;
[0032] Figure 2 A flowchart of another data comparison method provided in an embodiment of the present application; and
[0033] Figure 3 A schematic diagram of the structure of a data comparison device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0035] The data comparison method and device of the embodiments of the present application are described below with reference to the accompanying drawings.
[0036] Figure 1 A flowchart of a data comparison method provided in an embodiment of the present application.
[0037] like Figure 1 As shown, the data comparison method includes the following steps:
[0038] Step 101, obtain the Mybatis file corresponding to the target system and the SQL file of the database structure.
[0039] The target system may be a sales expense management system, etc. This disclosure does not limit this.
[0040] In some embodiments, the project file corresponding to the target system is first obtained, and then the directory of the project file is traversed to determine that the file whose name contains preset keywords and is in XML format is a Mybatis file.
[0041] Specifically, pull the project files of the target system through Python files, use pythongit dependencies, configure the git address and authentication information, and obtain the project files through git clone. Recursively search the overall directory of the project, obtain all .xml files, and determine whether they belong to Mybatis files by whether the name contains the dao keyword.
[0042] In some embodiments, a database server is remotely connected via a python file, and an SQL file of the database structure is obtained via an expdp command. Alternatively, the SQL can be directly prepared and parameters can be passed in.
[0043] Step 102, formatting the SQL file of the database structure to obtain formatted data corresponding to the database structure.
[0044] In some embodiments, the SQL file of the database structure can be parsed, and keywords such as tables, views, sequences, fields, indexes, etc. can be extracted and stored in a formatted manner.
[0045] In some embodiments, the formatted data may include the structure type, structure name, involved table, and involved field corresponding to each SQL statement in the SQL file.
[0046] For example, the SQL statement contained in the SQL file is:
[0047] "--table1 table creation statement
[0048] create table table1{
[0049] Column1 varchar(10),
[0050] Column2 varchar(10)
[0051] };
[0052] --table2 table creation statement
[0053] create table table2{
[0054] Column3 varchar(10),
[0055] Column4 varchar(10)
[0056] };
[0057] --i_table1 index / create statement
[0058] create index i_table1 on table1(column1);
[0059] --i_table2 table creation statement
[0060] create index i_table2 on table2(Column4);”
[0061] You can analyze the structure statements one by one in the order of the ending symbol;, and characterize the structure statements with create table and create index as keywords, that is, create table statements or create index statements. Then, through regular expressions, match keywords such as create table, {,}, create index, on, (,) and extract the table names table1, table2; related fields Column1, Column2, Column3, Column4. And the index names i_table1, i_table2; related tables table1, table2; related fields Column1, Column4. The final formatting results are shown in Table 1 below:
[0062] Table 1
[0063] Structure Type Structure Name Involved table Fields involved table table1 table1 column1; column2 table table2 table2 column3; column4 index i_table1 table1 column1 index i_table2 table2 column4
[0064] Step 103, based on the XML regular expression, parse each SQL tag in the XML file in the Mybatis file to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag.
[0065] The tag type may include delete, update, select, insert, etc. This disclosure does not limit this.
[0066] In some embodiments, the core logic of the XML regular expression can be: starting with the SQL tag <, id, parameterType, resultType as keywords, ending with the tag, extracting <tag type>, the value of id=, the value of parameterType=, the value of resultType= and the logical SQL content.
[0067] For example, the SQL tag of the query type can be:
[0068] “ <select id="selectdemo"parametertype="string"resulttype="object">
[0069] Select t1.Column1,t1.Column2,t2.Column3
[0070] From table1 t1,table2 t2
[0071] Where t1.Column1=t2.Column3
[0072] and t1.Column1=#{Column1,jdbcType=VARCHAR}
[0073] Order by t1.Column1;
[0074] < / select> ”
[0075] Based on XML regular expressions, the result after parsing the SQL tags can be:
[0076] "Tag type: select
[0077] id value: selectDemo
[0078] parameterType value: string
[0079] resultType value: object
[0080] Logical SQL content:
[0081] Select t1.Column1,t1.Column2,t2.Column3
[0082] From table1 t1,table2 t2
[0083] Where t1.Column1=t2.Column3
[0084] and t1.Column1=#{Column1,jdbcType=VARCHAR}
[0085] Order by t1.Column1;"
[0086] Among them, the tag type is the qualitative type of the sql tag, including select, update, delete, insert, etc.
[0087] The value of id is the id of the sql tag in this section, which distinguishes the uniqueness.
[0088] The value of parameterType is the request parameter type.
[0089] Among them, the value of resultType: return parameter type.
[0090] Step 104: Parse the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain key content included in the logical SQL content.
[0091] It should be noted that the structure of the logical SQL content corresponding to different tag types is different. Therefore, it is necessary to set a corresponding regular expression for each tag type, so that each logical SQL content can be parsed based on the SQL regular expression corresponding to each tag type to accurately extract the key content.
[0092] The core logic of the SQL regular expression corresponding to each tag type can be: based on the keywords of the SQL standard syntax, such as select, update, delete, insert, from, where, set, values, and, or, exists, not exits, in, not in, order by, group by, having, limit, etc., extract the key contents such as the fields, table names, conditions, aggregation conditions, etc. at the corresponding positions.
[0093] For example, after parsing the logical SQL content of the above query type, the key content obtained may include:
[0094] "SQL type: select
[0095] Select fields: t1.Column1; t1.Column2; t2.Column3
[0096] Select-From table:table1 t1; table2 t2
[0097] Where condition:
[0098] t1.Column1=t2.Column3; t1.Column1=#{Column1,jdbcType=VARCHAR}
[0099] Sort condition: t1.Column1
[0100] Aggregation conditions: None
[0101] The relationship between tables and fields involved (shown as key-value):
[0102] {
[0103] "table1":["Column1","Column2"],
[0104] "table2":["Column3"]
[0105] }”
[0106] Among them, SQL type: characterizes the SQL content, including select, update, delete, insert, etc.
[0107] Among them, Select field: extract the query field according to the SQL type of the query.
[0108] Among them, Select-From table: extract the query table according to the SQL type of the query.
[0109] Among them, Where condition: the condition part of SQL, extracting related fields and associations.
[0110] Among them, sorting condition: extract the sorting condition field according to the SQL type of the query, such as order by.
[0111] Aggregation condition: extracts the aggregation condition field based on the SQL type of the query, such as group by.
[0112] Step 105 : Compare the key content corresponding to each SQL tag with the formatted data to obtain a comparison result.
[0113] In the disclosed embodiment, after determining the key content and formatted data corresponding to each SQL tag, the key content corresponding to each SQL tag can be compared with the formatted data, so as to quickly determine whether each SQL tag in the Mybatis file exists correctly in the database structure.
[0114] In this embodiment, the Mybatis file corresponding to the target system and the SQL file of the database structure are obtained; the SQL file of the database structure is formatted to obtain the formatted data corresponding to the database structure; based on the XML regular expression, each SQL tag in the XML file in the Mybatis file is parsed to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag; based on the SQL regular expression corresponding to the tag type, the logical SQL content is parsed to obtain the key content contained in the logical SQL content; the key content corresponding to each SQL tag is compared with the formatted data to obtain the comparison result. Thus, the content of each SQL tag in the Mybatis file can be extracted based on the regular expression, and then the extracted key content is compared with the formatted data corresponding to the SQL file of the database structure, so that it can be quickly and accurately determined whether each SQL tag in the Mybatis file exists correctly in the database structure.
[0115] Figure 2 The following is a flow chart of a data comparison method provided in an embodiment of the present application. Figure 2 As shown, the data comparison method may include the following steps:
[0116] Step 201, obtain the Mybatis file corresponding to the target system and the SQL file of the database structure.
[0117] Step 202, formatting the SQL file of the database structure to obtain formatted data corresponding to the database structure.
[0118] Step 203, based on the XML regular expression, parse each SQL tag in the XML file in the Mybatis file to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag.
[0119] Step 204: Parse the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain key content included in the logical SQL content.
[0120] The specific implementation forms of steps 201 to 204 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0121] Step 205: Obtain the target comparison strategy corresponding to the tag type.
[0122] Step 206 : Based on the target comparison strategy, the key content is compared with the formatted data to obtain a comparison result.
[0123] In some embodiments, when the formatted data includes the structure type, structure name, involved table, and involved field corresponding to each SQL statement in the SQL file, it can be preferentially determined whether the target query table included in the key content exists in the formatted data.
[0124] In some embodiments, based on the target query table contained in the key content, the structure type and structure name corresponding to each SQL statement in the formatted data can be traversed. When each SQL statement in the formatted data does not contain a structure type of table and a structure name of the target query table, it is determined that the comparison result corresponding to the SQL tag belonging to the key content is a matching failure, and the reason for the failure is recorded.
[0125] Taking the key content and Table 1 in the above example as an example, through the target query tables table1 and table2 in the Select-From table field, format the contents of the data with a structure type of table and a structure name of table1 or table2 one by one, that is, determine whether table1 and table2 exist in the database structure.
[0126] If both table1 and table2 do not exist in the formatted data, it means that table1 and table2 do not exist in the database structure. The comparison result corresponding to this SQL tag is match failure, and the reason for the failure is that table1 does not exist in the database structure, or table2 does not exist in the database structure.
[0127] As shown in Table 1, table1 and table2 exist in the formatted data, that is, the match is successful. In the case where it is determined that the formatted data contains the target query table included in the key content, it can be further determined whether the target query table in the formatted data has a field corresponding to the target query table in the key content.
[0128] In some embodiments, the SQL statement corresponding to the target query table in the formatted data whose structure type is a table and whose structure name is a target query table is determined to be a first SQL statement, and based on the target field corresponding to the target query table in the key content, the involved fields corresponding to the first SQL statement in the formatted data are traversed. When the involved fields corresponding to the first SQL statement are different from the target fields, the comparison result corresponding to the SQL tag belonging to the key content is determined to be a match failure, and the reason for the failure is recorded.
[0129] Taking the key content and Table 1 in the above example as an example, if table1 and table2 exist in the formatted data, the SQL statement corresponding to the second row of Table 1 and the SQL statement corresponding to the third row are determined as the first SQL statement, and the target fields column1 and column2 corresponding to table1 in the key content are matched with the involved fields column1 and column2 in the second row of Table 1, and the target field column3 corresponding to table2 in the key content is matched with the involved fields column3 and column4 in the third row of Table 1.
[0130] If the target field corresponding to any target query table fails to match, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a match failure, and the reason for the failure is that the target field corresponding to any target query table does not exist in the database structure.
[0131] As shown in Table 1, the target fields column1 and column2 corresponding to table1 and the target field column3 corresponding to table2 exist in the formatted data, that is, the match is successful. In the case of a successful match, it can be further determined whether there is an index relationship between the target fields of the target query table in the key content in the formatted data. The following steps may be included:
[0132] (1) When the involved field corresponding to the first SQL statement is the same as the target field, and the key content includes an index relationship between a first target field of the first target query table and a second target field of the second target query table, based on the first target query table and the corresponding first target field and the second target query table and the corresponding second field in the index relationship, the structure type, involved table, and involved field corresponding to each SQL statement in the formatted data are traversed;
[0133] As shown in the key content of the above example, the first target query table is table1, the second target query table is table2, and the index relationship is "t1.Column1=t2.Column3". Based on table1 and the corresponding first target field Column1, and the corresponding second target field Column3 of table2, the structure type, involved tables, and involved fields corresponding to each SQL statement in the formatted data are traversed to determine whether there is an index relationship of "t1.Column1=t2.Column3" in the formatted data.
[0134] (2) In the case where there is an SQL statement in the formatted data whose corresponding structure type is index, whose involved table is the first target query table, and whose involved field is the first target field, and another SQL statement whose corresponding structure type is index, whose involved table is the second target query table, and whose involved field is the second target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a successful match;
[0135] (3) When there is no SQL statement in the formatted data whose corresponding structure type is index, whose involved table is the first target query table, whose involved field is the first target field, and / or there is no SQL statement whose corresponding structure type is index, whose involved table is the second target query table, and whose involved field is the second target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a matching failure, and the reason for the failure is recorded.
[0136] As shown in the key content and Table 1 in the above example, the structure type in the third row of Table 1 is index, the table involved is table1, and the field involved is column1, which is different from the first target field Column1 corresponding to table1 in the key content, but the structure type in the fourth row is index, the table involved is table2, and the field involved is column4, which is different from the second target field Column3 corresponding to table2 in the key content. The comparison result is a match failure. The reason for the failure is that the index relationship "t1.Column1=t2.Column3" does not exist in the database structure.
[0137] In the disclosed embodiment, the Mybatis file corresponding to the target system and the SQL file of the database structure are obtained; the SQL file of the database structure is formatted to obtain the formatted data corresponding to the database structure; based on the XML regular expression, each SQL tag in the XML file in the Mybatis file is parsed to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag; based on the SQL regular expression corresponding to the tag type, the logical SQL content is parsed to obtain the key content contained in the logical SQL content; the target comparison strategy corresponding to the tag type is obtained; based on the target comparison strategy, the key content is compared with the formatted data to obtain the comparison result. Thus, the key content can be compared with the formatted data based on the target comparison strategy corresponding to each tag type, so that it can be more quickly and accurately determined whether each SQL tag in the Mybatis file exists correctly in the database structure.
[0138] In some embodiments, the key content and comparison result corresponding to each SQL tag may also be formatted and stored, wherein if the comparison result is a comparison failure, the failure reason corresponding to the comparison failure is stored.
[0139] In some embodiments, the formatted and stored key content and the comparison results may also be displayed, so that the comparison results can be clearly presented.
[0140] For example, the key content and comparison results corresponding to each SQL tag stored in the format may include: tag type, table, field, condition, comparison result, failure reason, etc. corresponding to the SQL tag. The present disclosure does not limit this.
[0141] In order to implement the above embodiment, the present application also proposes a data comparison device.
[0142] Figure 3 This is a schematic diagram of the structure of a data comparison device provided in an embodiment of the present application. Figure 3 As shown, the data comparison device comprises:
[0143] Acquisition module 301, used to acquire the Mybatis file corresponding to the target system and the SQL file of the database structure;
[0144] Processing module 302, used to format the SQL file of the database structure to obtain formatted data corresponding to the database structure;
[0145] The first parsing module 303 is used to parse each SQL tag in the XML file in the Mybatis file based on the XML regular expression to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag;
[0146] The second parsing module 304 is used to parse the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain the key content included in the logical SQL content;
[0147] The comparison module 305 is used to compare the key content corresponding to each SQL tag with the formatted data to obtain a comparison result.
[0148] In some embodiments, the comparison module 305 is used to:
[0149] Get the target comparison strategy corresponding to the label type;
[0150] Based on the target comparison strategy, key content is compared with formatted data to obtain comparative results.
[0151] In some embodiments, the comparison module 305 is used to:
[0152] Based on the target query table contained in the key content, the structure type and structure name corresponding to each SQL statement in the formatted data are traversed;
[0153] When each SQL statement in the formatted data does not include a structure type of table and a structure name of the target query table, it is determined that a comparison result corresponding to an SQL tag to which the key content belongs is a match failure, and the reason for the failure is recorded.
[0154] In some embodiments, the comparison module 305 is used to:
[0155] Determine the SQL statement corresponding to the structure type of the table and the structure name of the target query table in the formatted data as the first SQL statement;
[0156] Based on the target field corresponding to the target query table in the key content, traverse the involved fields corresponding to the first SQL statement in the formatted data;
[0157] In the case where the involved field corresponding to the first SQL statement is different from the target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a match failure, and the reason for the failure is recorded.
[0158] In some embodiments, the comparison module 305 is used to:
[0159] In a case where the involved field corresponding to the first SQL statement is the same as the target field, and the key content includes an index relationship between a first target field of the first target query table and a second target field of the second target query table, based on the first target query table and the corresponding first target field and the second target query table and the corresponding second field in the index relationship, traverse the structure type, involved table, and involved field corresponding to each SQL statement in the formatted data;
[0160] When there is an SQL statement in the formatted data whose corresponding structure type is index, whose involved table is the first target query table, whose involved field is the first target field, and another SQL statement whose corresponding structure type is index, whose involved table is the second target query table, whose involved field is the second target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a successful match;
[0161] When there is no SQL statement in the formatted data whose corresponding structure type is index, the table involved is the first target query table, and the field involved is the first target field, and / or there is no SQL statement whose corresponding structure type is index, the table involved is the second target query table, and the field involved is the second target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a match failure, and the reason for the failure is recorded.
[0162] In some embodiments, a storage module is further included for:
[0163] The key content and comparison result corresponding to each SQL tag are formatted and stored. If the comparison result is a comparison failure, the failure reason corresponding to the comparison failure is stored.
[0164] In some embodiments, the acquisition module 301 is used to:
[0165] First obtain the project file corresponding to the target system;
[0166] Traverse the directory of the project file and identify the files whose names contain preset keywords and are in XML format as Mybatis files.
[0167] It should be noted that the above explanations of the data comparison method embodiment are also applicable to the data comparison device of this embodiment, and will not be repeated here.
[0168] In the disclosed embodiment, the Mybatis file corresponding to the target system and the SQL file of the database structure are obtained; the SQL file of the database structure is formatted to obtain the formatted data corresponding to the database structure; based on the XML regular expression, each SQL tag in the XML file in the Mybatis file is parsed to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag; based on the SQL regular expression corresponding to the tag type, the logical SQL content is parsed to obtain the key content contained in the logical SQL content; the key content corresponding to each SQL tag is compared with the formatted data to obtain the comparison result. Thus, the content of each SQL tag in the Mybatis file can be extracted based on the regular expression, and then the extracted key content is compared with the formatted data corresponding to the SQL file of the database structure, so that it can be quickly and accurately determined whether each SQL tag in the Mybatis file exists correctly in the database structure.
[0169] In order to implement the above embodiments, the present application also proposes an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided by the above embodiments.
[0170] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the methods provided by the above embodiments.
[0171] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which implements the methods provided by the above embodiments when executed by a processor.
[0172] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0173] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.
[0174] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.
[0175] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0176] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0177] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0178] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0179] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0180] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0181] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0182] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A data comparison method, characterized in that: The following steps are involved: Get the Mybatis file corresponding to the target system and the SQL file of the database structure; Formatting the SQL file of the database structure to obtain formatted data corresponding to the database structure; Based on XML regular expressions, parse each SQL tag in the XML file in the Mybatis file to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag; Parsing the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain key content included in the logical SQL content; The key content corresponding to each SQL tag is compared with the formatted data to obtain a comparison result.
2. The method according to claim 1, characterized in that The step of comparing the key content corresponding to each SQL tag with the formatted data to obtain a comparison result includes: Obtaining a target comparison strategy corresponding to the tag type; Based on the target comparison strategy, the key content is compared with the formatted data to obtain the comparison result.
3. The method according to claim 2, characterized in that The formatted data includes the structure type, structure name, involved table, and involved field corresponding to each SQL statement in the SQL file. Based on the target comparison strategy, the key content is compared with the formatted data to obtain the comparison result, including: Based on the target query table contained in the key content, traverse the structure type and structure name corresponding to each SQL statement in the formatted data; When each SQL statement in the formatted data does not include a structure type of table and a structure name of the target query table, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a matching failure, and the reason for the failure is recorded.
4. The method according to claim 3, characterized in that After traversing the structure type and structure name corresponding to each SQL statement in the formatted data based on the target query table included in the key content, the method further includes: Determine the SQL statement corresponding to the target query table in the formatted data whose structure type is a table and whose structure name is the first SQL statement; Based on the target field corresponding to the target query table in the key content, traverse the involved fields corresponding to the first SQL statement in the formatted data; In the case where the involved field corresponding to the first SQL statement is different from the target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a match failure, and the reason for the failure is recorded.
5. The method according to claim 4, characterized in that After traversing the involved fields corresponding to the first SQL statement in the formatted data based on the target field corresponding to the target query table in the key content, the method further includes: In a case where the involved field corresponding to the first SQL statement is the same as the target field, and the key content includes an index relationship between a first target field of a first target query table and a second target field of a second target query table, based on the first target query table and the corresponding first target field and the second target query table and the corresponding second field in the index relationship, traversing the structure type, involved table, and involved field corresponding to each SQL statement in the formatted data; When there is an SQL statement in the formatted data whose corresponding structure type is index, whose involved table is the first target query table, and whose involved field is the first target field, and another SQL statement whose corresponding structure type is index, whose involved table is the second target query table, and whose involved field is the second target field, determining that the comparison result corresponding to the SQL tag to which the key content belongs is a successful match; When there is no SQL statement in the formatted data whose corresponding structure type is index, the table involved is the first target query table, and the field involved is the first target field, and / or there is no other SQL statement whose corresponding structure type is index, the table involved is the second target query table, and the field involved is the second target field, it is determined that the comparison result corresponding to the SQL tag to which the key content belongs is a match failure, and the reason for the failure is recorded.
6. The method according to claim 1, characterized in that: After comparing the key content corresponding to each SQL tag with the formatted data to obtain a comparison result, the method further includes: The key content and comparison result corresponding to each SQL tag are formatted and stored, wherein if the comparison result is a comparison failure, the failure reason corresponding to the comparison failure is stored.
7. The method according to any one of claims 1 to 6, characterized in that: The Mybatis file corresponding to the target system is obtained, including: First, obtain the engineering file corresponding to the target system; The directory of the project file is traversed, and the file whose name contains preset keywords and is in XML format is determined as the Mybatis file.
8. A data comparison device, characterized in that: include: The acquisition module is used to obtain the Mybatis file corresponding to the target system and the SQL file of the database structure; A processing module, used for formatting the SQL file of the database structure to obtain formatted data corresponding to the database structure; The first parsing module is used to parse each SQL tag in the XML file in the Mybatis file based on XML regular expressions to obtain the tag type of the SQL tag and the logical SQL content contained in the SQL tag; A second parsing module, used to parse the logical SQL content based on the SQL regular expression corresponding to the tag type to obtain key content included in the logical SQL content; The comparison module is used to compare the key content corresponding to each SQL tag with the formatted data to obtain a comparison result.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Patent Citations
SQL method and device for analyzing XML and Java files, equipment and storage medium
CN113704575A
Mapping file verification method and device and related equipment
CN117251371A
SQL (Structured Query Language) statement management method and device, electronic equipment and storage medium
CN117608582A
Code scanning method for detecting field difference between Mybatis Mapper XML and database
CN118485057A