Adaptation result determination method and device, equipment, medium and program product
By automatically generating and executing SQL statements, the problem of low efficiency of SQL statement template adaptation in the existing technology is solved, fast and accurate determination of adaptation results is achieved, and the efficiency of database system switching is improved.
Patent Information
- Application Number
- CN202410776429.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-06
AI Technical Summary
In the existing technology, developers need to manually check whether the format of each SQL statement template is adapted to the target database system one by one, resulting in low efficiency.
By obtaining the mapper interface, determine the parameter type in the database operation method, generate parameter values in a random manner, generate the target SQL statement, execute and judge its adaptation results, and automatically determine the adaptation results of the SQL statement template.
It improves the efficiency of determining the SQL statement template adaptation results, realizes the rapid adaptation of large batches of SQL statement templates, and improves the efficiency of database system switching.
Smart Images

Figure CN118606344A
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a method, device, equipment, medium and program product for determining an adaptation result. Background Art
[0002] When the business of an application of the initial database system needs to be migrated to the target database system, it may involve modifying the format of the application's Structured Query Language (SQL) statement template. Therefore, it is necessary to determine whether the format of each SQL statement template is compatible with the target database system.
[0003] In the related art, developers are required to manually check all SQL statement templates one by one to determine whether the format of each SQL statement template is compatible with the target database system, that is, to determine the adaptation result of each SQL statement template.
[0004] However, the method in the related art requires developers to manually check all SQL statement templates one by one, which has the problem of low efficiency in determining the adaptation results. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, device, medium and program product for determining an adaptation result, which can quickly determine the adaptation result of each SQL statement template and improve the efficiency of determining the adaptation result.
[0006] In a first aspect, an embodiment of the present application provides a method for determining an adaptation result, including:
[0007] Obtain a mapper interface; the mapper interface includes at least one database operation method, and the database operation method includes at least one parameter;
[0008] For each database operation method, determine the parameter type of each parameter in the database operation method, and generate a parameter value of each parameter in a random manner according to the parameter type of each parameter;
[0009] According to the database operation method, determining at least one corresponding structured query language SQL statement template; the SQL statement template includes at least one target parameter;
[0010] For each SQL statement template, determine the parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method;
[0011] Obtain a target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template;
[0012] Execute the target SQL statement, obtain the execution result, and determine the adaptation result of the SQL statement template according to the execution result.
[0013] In one implementation, the parameter value of each parameter is generated in a random manner according to the parameter type of each parameter, including:
[0014] Determine the number of parameters of all parameters in the database operation method;
[0015] Get at least one parameter list;
[0016] Compare the parameter type of each parameter and the parameter quantity of all parameters in the database operation method with the parameter type of at least one historical parameter and the parameter quantity of all historical parameters in each parameter list to determine whether the target parameter list exists in at least one parameter list;
[0017] When the target parameter list does not exist in at least one parameter list, a parameter value of each parameter is generated randomly according to the parameter type of each parameter;
[0018] In the case that there is a target parameter list in at least one parameter list, a parameter value of each parameter is determined according to the target parameter list and a parameter type of each parameter.
[0019] In one implementation, the method further includes:
[0020] A parameter list is generated according to the parameter value of each parameter in the database operation method, the parameter type of each parameter, and the parameter quantity of all parameters, and the parameter list is stored.
[0021] In one implementation, the parameter value of each parameter is generated in a random manner according to the parameter type of each parameter, including:
[0022] For each parameter, determining whether to store the parameter value of the target historical parameter; wherein the parameter type of the target historical parameter is the same as the parameter type of the parameter;
[0023] In the case of determining to store the parameter value of the target historical parameter, determining the parameter value of the target historical parameter as the parameter value of the parameter;
[0024] In the case where it is determined that the parameter value of the target historical parameter is not stored, the parameter value of the parameter is generated in a random manner according to the parameter type of the parameter.
[0025] In one implementation, determining the adaptation result of the SQL statement template according to the execution result includes:
[0026] When the execution result is the first execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is adapted to the target database system;
[0027] When the execution result is the second execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is not compatible with the target database system.
[0028] In one implementation, executing a target SQL statement and obtaining an execution result includes:
[0029] Execute the target SQL statement and get the exception information;
[0030] When it is determined that the length of the abnormal information is greater than 0, determining that the execution result is the second execution result;
[0031] When it is determined that the length of the abnormal information is 0, the execution result is determined to be the first execution result.
[0032] In one implementation, the method further includes:
[0033] When the execution result is the second execution result, the database operation method corresponding to the SQL statement template, the parameter value of each target parameter in the SQL statement template, the execution result, the adaptation result, and / or the exception information are stored and processed.
[0034] In a second aspect, an embodiment of the present application provides a device for determining an adaptation result, including:
[0035] An acquisition module is used to acquire a mapper interface; the mapper interface includes at least one database operation method, and the database operation method includes at least one parameter;
[0036] A processing module, for determining, for each database operation method, a parameter type of each parameter in the database operation method, and generating a parameter value of each parameter in a random manner according to the parameter type of each parameter;
[0037] The processing module is further used to determine at least one corresponding structured query language SQL statement template according to the database operation method; the SQL statement template includes at least one target parameter;
[0038] The processing module is further used to determine, for each SQL statement template, a parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method;
[0039] The processing module is further used to obtain a target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template;
[0040] The processing module is also used to execute the target SQL statement, obtain the execution result, and determine the adaptation result of the SQL statement template according to the execution result.
[0041] In one implementation, the processing module is specifically configured to:
[0042] Determine the number of parameters of all parameters in the database operation method;
[0043] Get at least one parameter list;
[0044] Compare the parameter type of each parameter and the parameter quantity of all parameters in the database operation method with the parameter type of at least one historical parameter and the parameter quantity of all historical parameters in each parameter list to determine whether the target parameter list exists in at least one parameter list;
[0045] When the target parameter list does not exist in at least one parameter list, a parameter value of each parameter is generated randomly according to the parameter type of each parameter;
[0046] In the case that there is a target parameter list in at least one parameter list, a parameter value of each parameter is determined according to the target parameter list and a parameter type of each parameter.
[0047] In one implementation, the processing module is further configured to:
[0048] A parameter list is generated according to the parameter value of each parameter in the database operation method, the parameter type of each parameter, and the parameter quantity of all parameters, and the parameter list is stored.
[0049] In one implementation, the processing module is specifically configured to:
[0050] For each parameter, determining whether to store the parameter value of the target historical parameter; wherein the parameter type of the target historical parameter is the same as the parameter type of the parameter;
[0051] In the case of determining to store the parameter value of the target historical parameter, determining the parameter value of the target historical parameter as the parameter value of the parameter;
[0052] In the case where it is determined that the parameter value of the target historical parameter is not stored, the parameter value of the parameter is generated in a random manner according to the parameter type of the parameter.
[0053] In one implementation, the processing module is specifically configured to:
[0054] When the execution result is the first execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is adapted to the target database system;
[0055] When the execution result is the second execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is not compatible with the target database system.
[0056] In one implementation, the processing module is specifically configured to:
[0057] Execute the target SQL statement and get the exception information;
[0058] When it is determined that the length of the abnormal information is greater than 0, determining that the execution result is the second execution result;
[0059] When it is determined that the length of the abnormal information is 0, the execution result is determined to be the first execution result.
[0060] In one implementation, the processing module is further configured to:
[0061] When the execution result is the second execution result, the database operation method corresponding to the SQL statement template, the parameter value of each target parameter in the SQL statement template, the execution result, the adaptation result, and / or the exception information are stored and processed.
[0062] In a third aspect, an embodiment of the present application provides a computing device, including:
[0063] A processor, and a memory communicatively connected to the processor;
[0064] Memory is used to store computer executable instructions;
[0065] The processor is used to execute the computer-executable instructions stored in the memory to implement the method for determining the adaptation result of the first aspect.
[0066] In a fourth aspect, an embodiment of the present application provides 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 method for determining the adaptation result of the first aspect.
[0067] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the method for determining the adaptation result of the first aspect.
[0068] The embodiment of the present application provides a method, device, equipment, medium and program product for determining an adaptation result. In the method, a computing device can traverse each mapper interface. For each database operation method in the mapper interface, the computing device can determine the parameter value of each parameter in the database operation method in a random manner based on the parameter type of each parameter, and then determine the parameter value of each target parameter in each SQL statement template corresponding to the database operation method. The computing device can generate a target SQL statement based on the parameter value of each target parameter in the SQL statement template and the SQL statement template, and then execute the target SQL statement to determine the adaptation result of the SQL statement template based on the execution result. Through the above method, the adaptation result of the SQL statement template can be determined quickly and accurately, and the efficiency of determining the adaptation result is improved. In addition, through the above method, the rapid determination of the adaptation results of a large number of SQL statement templates can be achieved, the efficiency of determining the adaptation results of a large number of SQL statement templates is improved, and the efficiency of database system switching is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technical descriptions. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0070] Figure 1 A schematic diagram of an application scenario applicable to an embodiment of the present application;
[0071] Figure 2 A flowchart of a method for determining an adaptation result provided in an embodiment of the present application;
[0072] Figure 3 A flowchart of a second embodiment of a method for determining an adaptation result provided in an embodiment of the present application;
[0073] Figure 4 A flowchart of a third embodiment of a method for determining an adaptation result provided in an embodiment of the present application;
[0074] Figure 5 A schematic diagram of the structure of a device for determining an adaptation result provided in an embodiment of the present application;
[0075] Figure 6 A structural diagram of a computing device provided for this application. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments made by ordinary technicians in this field under the enlightenment of the embodiments belong to the scope of protection of the present application.
[0077] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0078] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.
[0079] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0080] When a user wants to migrate the business of an application in an initial database system to a target database system, so that services provided by the initial database system for the application are switched to services provided by the target database system, there may be a situation where the target database system cannot recognize the format of the Structured Query Language (SQL) statement template in the application, that is, there may be a situation where the format of the SQL statement template is incompatible with the target database system.
[0081] Therefore, it is necessary to filter out the SQL statement templates whose formats are not compatible with the target database system from all the SQL statement templates corresponding to the application, and modify the formats of the filtered SQL statement templates one by one.
[0082] In the related art, developers are required to manually check all SQL statement templates one by one to determine whether the format of each SQL statement template is compatible with the target database system, that is, to determine the adaptation result of each SQL statement template.
[0083] However, the method in the related art requires developers to manually check all SQL statement templates one by one, which has the problem of low efficiency in determining the adaptation results.
[0084] Based on the above technical problems, the embodiment of the present application provides a method for determining an adaptation result. The computing device can determine the parameter value of each parameter in the database operation method (recorded in the mapper interface) in a random manner based on the parameter type of each parameter, and then determine the parameter value of each target parameter in each SQL statement template corresponding to the database operation method. The computing device can generate a target SQL statement based on the parameter value of each target parameter in the SQL statement template and the SQL statement template, and then execute the target SQL statement to determine the adaptation result of the SQL statement template based on the execution result, thereby improving the efficiency of determining the adaptation result.
[0085] For ease of understanding, the following Figure 1 The examples are used to illustrate the application scenarios to which the embodiments of the present application are applicable.
[0086] For example, Figure 1 Schematic diagram of an application scenario applicable to the embodiment of the present application. Figure 1 As shown, the application scenarios include:
[0087] Application 101, initial database system 102, and target database system 103. Application 101 can be connected to initial database system 102 for communication, and application 101 can also be connected to target database system 103 for communication.
[0088] The application 101 may be run on a computing device. It should be noted that the computing device may be a terminal device, a server, or a server cluster, which is not limited in the present embodiment.
[0089] The initial database system 102 may be deployed on a first database server. It should be noted that the first database server may be a single server or a server cluster consisting of multiple servers.
[0090] The target database system 103 may be deployed on a second database server. It should be noted that the second database server may be a single server or a server cluster consisting of multiple servers.
[0091] When application 101 needs the initial database system 102 to provide services for application 101, the computing device where application 101 is located can be connected to the first database server where the initial database system 102 is located; when application 101 needs the target database system 103 to provide services for application 101, the computing device where application 101 is located can be connected to the second database server where the target database system 103 is located.
[0092] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0093] Figure 2 A flowchart of a method for determining an adaptation result provided in an embodiment of the present application is provided. Figure 2 , the method specifically comprises the following steps:
[0094] S201: Get a mapper interface.
[0095] In this embodiment, when the computing device needs the target database system to provide services for the application program running on the computing device, the computing device can connect to the second database server where the target database system is located. It should be noted that the computing device can connect to the second database server based on the database connection information. It should also be noted that the database connection information of different database servers is different.
[0096] When the computing device is connected to the second database server, the computing device can traverse (scan) the code base of the application program to obtain at least one mapper interface among all interfaces. The mapper interface is an interface with the @Mapper annotation. It can be understood that the application program can be a Java application program.
[0097] Based on at least one database operation method recorded in each mapper interface, the computing device can obtain each database operation method in each mapper interface. Exemplarily, the database operation method can be a query method "UserselectUserByName (String name)".
[0098] Based on the fact that each database operation method includes at least one parameter, the computing device can traverse each database operation method to obtain each parameter. Exemplarily, a parameter of a database operation method can be name, and a parameter of a database operation method can be age. In addition, it should be noted that the database operation method also includes the parameter type of the parameter. For example, for the parameter name, the database operation method includes the parameter type String of the parameter. For another example, for the parameter age, the database operation method includes the parameter type int of the parameter.
[0099] S202: for each database operation method, determine the parameter type of each parameter in the database operation method, and generate a parameter value of each parameter in a random manner according to the parameter type of each parameter.
[0100] In this embodiment, for each database operation method, the computing device can determine the parameter type of each parameter after obtaining each parameter in the database operation method. In one implementation, the computing device can use a Java method such as Java.method.getParameterTypes() to obtain a parameter type array corresponding to the database operation method. The parameter type array includes the parameter type of each parameter in the database operation method.
[0101] The computing device can generate the parameter value of each parameter in a random manner according to the parameter type of each parameter. By randomly generating parameter values based on parameter types, the actual business scenario can be simulated, and the boundary conditions and abnormal conditions can be fully covered, so that the adaptation result of the SQL statement template can be fully determined.
[0102] In one implementation, when the parameter type of the parameter belongs to a basic data type, the computing device may directly generate a random number in a random manner (using the Random class in Java), and determine the random number as the parameter value of the parameter. Exemplarily, when the parameter type of the parameter is int, long, float, double, boolean, or char, the computing device may determine that the parameter type of the parameter belongs to a basic data type.
[0103] In one implementation, when the parameter type of the parameter is a string type, the computing device may generate a target string in a random manner based on the acquired business information, and determine the target string as the parameter value of the parameter. For example, the computing device may generate a target string, Zhang San, in a random manner based on the business information being a Chinese name. For another example, the computing device may generate a target string, Tom, in a random manner based on the business information being an English name.
[0104] In one implementation, when the parameter type of the parameter is a string type, the computing device may generate a string that conforms to a preset regular expression.
[0105] In one implementation, when the parameter type of the parameter belongs to a complex data type, the computing device may adopt a recursive analysis method to analyze each attribute of the parameter layer by layer, and adopt a random method to generate a random value corresponding to each attribute, and determine the random value as the parameter value of the parameter. Exemplarily, when the parameter type of the parameter is a custom object (the custom object belongs to a complex data type), the computing device may determine that the parameter type of the parameter belongs to a complex data type. The computing device may adopt a recursive analysis method to analyze each attribute of the parameter layer by layer, and adopt a random method to generate a random value corresponding to the attribute, and determine the random value of the attribute as the parameter value of the parameter. In one implementation, the computing device may determine a corresponding generation strategy according to the type of the attribute, and generate a random value corresponding to the attribute according to the corresponding generation strategy. In one implementation, the computing device may determine an association relationship between multiple parameters, and according to the association relationship between the multiple parameters, adopt a random method to generate a parameter value of each parameter. There is an association relationship between the parameter values of each parameter. For example, the first parameter is the student's student ID number, and the second parameter is the student's reporting time. The computing device can generate a parameter value of the reporting time in a random manner based on the association between the student ID number and the reporting time, and then generate a parameter value of the student ID number based on the parameter value of the reporting time.
[0106] In one implementation, when the parameter type of the parameter belongs to a set type, the computing device may generate each element in a random manner. The computing device may form a set according to at least one element. The computing device may determine the set as the parameter value of the parameter. Exemplarily, when the parameter type of the parameter is List, Set, or Map, the computing device may determine that the parameter type of the parameter belongs to a set type.
[0107] In one implementation, when the parameter type of the parameter is a special type, the computing device may determine the parameter value of the parameter from a plurality of preset parameter values in a random manner. For example, when the parameter type of the parameter is an enumeration type, the computing device may determine that the parameter type of the parameter is a special type, the computing device may determine a target enumeration value from a plurality of preset enumeration values in a random manner, and determine the target enumeration value as the parameter value of the parameter. For another example, when the parameter type of the parameter is a date type, the computing device may determine that the parameter type of the parameter is a special type, the computing device may determine a target date from a plurality of preset dates (such as a plurality of preset dates included in a preset date range) in a random manner, and determine the target date as the parameter value of the parameter.
[0108] S203: Determine at least one corresponding structured query language SQL statement template according to the database operation method.
[0109] In this embodiment, the computing device may determine at least one corresponding structured query language SQL statement template according to the database operation method.
[0110] Each database operation method corresponds to an Extensible Markup Language (XML) file, which records at least one SQL statement template.
[0111] Each SQL statement template includes at least one target parameter. For a database operation method, all parameters in the database operation method are the same as all target parameters in all SQL statement templates corresponding to the database operation method. In other words, the target parameter in an SQL statement template belongs to all parameters in the database operation method corresponding to the SQL statement template.
[0112] S204: For each SQL statement template, determine the parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method.
[0113] In this embodiment, for each SQL statement template, the computing device may determine the parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method.
[0114] Specifically, based on all parameters in the database operation method, which are the same as all target parameters in all SQL statement templates corresponding to the database operation method, for a target parameter in the SQL statement template, the computing device can determine the parameter in the database operation method that corresponds to the target parameter, and determine the parameter value of the parameter as the parameter value of the target parameter.
[0115] S205: Obtain a target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template.
[0116] In this embodiment, for each SQL statement template, the computing device can obtain the target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template after determining the parameter value of each target parameter in the SQL statement template.
[0117] S206: Execute the target SQL statement to obtain an execution result, and determine the adaptation result of the SQL statement template according to the execution result.
[0118] In this embodiment, the computing device may execute the target SQL statement after acquiring the target SQL statement to obtain the execution result. In one implementation, the computing device may execute the target SQL statement to obtain the exception information. The computing device may determine that the execution result is the second execution result (such as execution failure or execution failure) when it is determined that the length of the exception information is greater than 0. The computing device may determine that the execution result is the first execution result (such as execution success or execution pass) when it is determined that the length of the exception information is 0.
[0119] The computing device may determine the adaptation result of the SQL statement template according to the execution result. Specifically, when the execution result is the first execution result, the computing device may determine that the adaptation result of the SQL statement template is that the format of the SQL statement template is adapted to the target database system; when the execution result is the second execution result, the computing device may determine that the adaptation result of the SQL statement template is that the format of the SQL statement template is not adapted to the target database system.
[0120] It should be noted that, in one implementation, when the execution result is the second execution result, the computing device may store and process the database operation method corresponding to the SQL statement template, the parameter value of each target parameter in the SQL statement template, the execution result, the adaptation result, and / or the exception information. In one implementation, when the execution result is the second execution result, the computing device may generate a test report based on the database operation method corresponding to the SQL statement template, the parameter value of each target parameter in the SQL statement template, the execution result, the adaptation result, and / or the exception information, and store and process the test report.
[0121] Beneficial effects of this embodiment: In this embodiment, the computing device can traverse each mapper interface. For each database operation method in the mapper interface, the computing device can determine the parameter value of each parameter in the database operation method in a random manner based on the parameter type of each parameter, and then determine the parameter value of each target parameter in each SQL statement template corresponding to the database operation method. The computing device can generate a target SQL statement based on the parameter value of each target parameter in the SQL statement template and the SQL statement template, and then execute the target SQL statement to determine the adaptation result of the SQL statement template based on the execution result. Through the above method, the adaptation result of the SQL statement template can be determined quickly and accurately, the efficiency of determining the adaptation result is improved, and the automatic acquisition of the adaptation result is realized. In addition, through the above method, the rapid determination of the adaptation results of a large number of SQL statement templates can be achieved, the efficiency of determining the adaptation results of a large number of SQL statement templates is improved, and the switching efficiency of the database system is improved.
[0122] On the basis of the first method embodiment, S202 in the first method embodiment is described below through the second method embodiment.
[0123] Figure 3 This is a flow chart of a second embodiment of a method for determining an adaptation result provided in an embodiment of the present application. Figure 3 , the method specifically comprises the following steps:
[0124] S301: For each database operation method, determine the parameter type of each parameter in the database operation method.
[0125] In this embodiment, for each database operation method, the computing device may determine the parameter type of each parameter in the database operation method.
[0126] In one implementation, the computing device may use Java.method.getParameterTypes() to obtain a parameter type array corresponding to the database operation method, wherein the parameter type array includes the parameter type of each parameter in the database operation method.
[0127] S302: Determine the number of parameters of all parameters in the database operation method.
[0128] In this embodiment, the computing device may determine the number of parameters of all parameters in the database operation method.
[0129] S303: Obtain at least one parameter list.
[0130] In this embodiment, for each database operation method, the computing device may use the parameter as a historical parameter after generating a parameter value of each parameter in the database operation method.
[0131] The computing device may construct a parameter list according to the parameter value of each historical parameter, the parameter type of each historical parameter, and the parameter quantity of all historical parameters in the database operation method, wherein the parameter list includes the parameter value of at least one historical parameter, the parameter type of at least one historical parameter, and the parameter quantity of all historical parameters.
[0132] The computing device may obtain at least one stored parameter list.
[0133] S304: Compare the parameter type of each parameter and the parameter quantity of all parameters in the database operation method with the parameter type of at least one historical parameter and the parameter quantity of all historical parameters in each parameter list to determine whether the target parameter list exists in at least one parameter list.
[0134] In this embodiment, the computing device may determine whether a target parameter list exists in at least one parameter list.
[0135] Specifically, the computing device may compare the parameter type of each parameter and the parameter quantity of all parameters in the database operation method with the parameter type of at least one historical parameter and the parameter quantity of all historical parameters in each parameter list to determine whether there is a target parameter list in at least one parameter list. The target parameter list records the parameter value of at least one target historical parameter, the parameter type of at least one target historical parameter, and the parameter quantity of all target historical parameters.
[0136] If it does not exist, execute S305; if it does exist, execute S306.
[0137] S305: Generate a parameter value of each parameter in a random manner according to the parameter type of each parameter.
[0138] In this embodiment, when it is determined that the target parameter list does not exist in at least one parameter list, the computing device may generate a parameter value for each parameter in a random manner according to the parameter type of each parameter.
[0139] It should be noted that the process of the computing device generating the parameter value of the parameter in a random manner according to the parameter type of the parameter has been described in S202 and will not be repeated here.
[0140] S306: Determine the parameter value of each parameter according to the target parameter list and the parameter type of each parameter in the database operation method.
[0141] In this embodiment, the computing device may determine the parameter value of each parameter according to the target parameter list and the parameter type of each parameter in the database operation method when it is determined that there is a target parameter list in at least one parameter list.
[0142] Specifically, for each parameter in the database operation method, the computing device can determine a target historical parameter from the target parameter list, wherein the parameter type of the target historical parameter is the same as the parameter type of the parameter, and the computing device can determine the parameter value of the parameter according to the parameter value of the target historical parameter.
[0143] In addition, it should be noted that after determining the parameter value of each parameter in the database operation method, the computing device can generate a parameter list according to the parameter value of each parameter in the database operation method, the parameter type of each parameter, and the parameter number of all parameters, and store the parameter list. It should be noted that each parameter can be regarded as a historical parameter. That is, the parameter list generated above records the parameter value of at least one historical parameter, the parameter type of at least one historical parameter, and the parameter number of all historical parameters.
[0144] Beneficial effects of this embodiment: For each database operation method, the computing device can determine the parameter type of each parameter in the database operation method. The computing device can determine the number of parameters of all parameters in the database operation method. The computing device can obtain at least one parameter list. The computing device can determine whether there is a target parameter list in at least one parameter list. The computing device can generate a parameter value for each parameter in a random manner according to the parameter type of each parameter when it is determined that there is a target parameter list in at least one parameter list. The computing device can determine the parameter value of each parameter according to the target parameter list and the parameter type of each parameter in the database operation method when it is determined that there is a target parameter list in at least one parameter list. In the above manner, the speed of determining the parameter value of the parameter can be improved, thereby improving the speed of determining the matching result.
[0145] Based on the method embodiment 1, S202 in the method embodiment 1 is described below through the method embodiment 3.
[0146] Figure 4 This is a flow chart of a third embodiment of a method for determining an adaptation result provided in an embodiment of the present application. Figure 4 , the method specifically comprises the following steps:
[0147] S401: For each database operation method, determine the parameter type of each parameter in the database operation method.
[0148] In this embodiment, for each database operation method, the computing device may determine the parameter type of each parameter in the database operation method.
[0149] In one implementation, the computing device may use Java.method.getParameterTypes() to obtain a parameter type array corresponding to the database operation method, wherein the parameter type array includes the parameter type of each parameter in the database operation method.
[0150] S402: For each parameter, determine whether to store the parameter value of the target historical parameter.
[0151] In this embodiment, for each parameter, the computing device may generate a parameter value of the parameter in a random manner according to the parameter type of the parameter, and then use the parameter as a historical parameter. The computing device may store the parameter value of the historical parameter and the parameter type of the historical parameter.
[0152] For each parameter, the computing device may determine whether the computing device stores the parameter value of the target historical parameter when determining the parameter value of the parameter. It should be noted that the parameter type of the target historical parameter is the same as the parameter type of the parameter, and the target historical parameter is a historical parameter of at least one historical parameter stored by the computing device.
[0153] If yes, execute S403; if no, execute S404.
[0154] S403: Determine the parameter value of the target historical parameter as the parameter value of the parameter.
[0155] In this embodiment, the computing device may determine the parameter value of the target historical parameter as the parameter value of the parameter when it is determined that the computing device stores the parameter value of the target historical parameter.
[0156] S404: Generate a parameter value of the parameter in a random manner according to the parameter type of the parameter.
[0157] In this embodiment, when it is determined that the computing device does not store the parameter value of the target historical parameter, the computing device may generate the parameter value of the parameter in a random manner according to the parameter type of the parameter.
[0158] It should be noted that the process of the computing device generating the parameter value of the parameter in a random manner according to the parameter type of the parameter has been described in S202 and will not be repeated here.
[0159] Beneficial effects of this embodiment: For each parameter, the computing device can determine whether to store the parameter value of the target historical parameter; the parameter type of the target historical parameter is the same as the parameter type of the parameter. The computing device can determine the parameter value of the target historical parameter as the parameter value of the parameter when determining to store the parameter value of the target historical parameter. The computing device can generate the parameter value of the parameter in a random manner according to the parameter type of the parameter when determining that the parameter value of the target historical parameter is not stored. In the above manner, the speed of determining the parameter value of the parameter can be increased, thereby increasing the speed of determining the matching result.
[0160] Figure 5 A schematic diagram of a structure of a device for determining an adaptation result provided in an embodiment of the present application. Figure 5 As shown, the adaptation result determination device 50 includes: an acquisition module 51 and a processing module 52. Among them,
[0161] The acquisition module 51 is used to acquire a mapper interface; the mapper interface includes at least one database operation method, and the database operation method includes at least one parameter;
[0162] The processing module 52 is used to determine the parameter type of each parameter in each database operation method, and generate the parameter value of each parameter in a random manner according to the parameter type of each parameter;
[0163] The processing module 52 is further used to determine at least one corresponding structured query language SQL statement template according to the database operation method; the SQL statement template includes at least one target parameter;
[0164] The processing module 52 is further used to determine, for each SQL statement template, a parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method;
[0165] The processing module 52 is further used to obtain a target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template;
[0166] The processing module 52 is further used to execute the target SQL statement, obtain the execution result, and determine the adaptation result of the SQL statement template according to the execution result.
[0167] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0168] In one implementation, the processing module 52 is specifically configured to:
[0169] Determine the number of parameters of all parameters in the database operation method;
[0170] Get at least one parameter list;
[0171] Compare the parameter type of each parameter and the parameter quantity of all parameters in the database operation method with the parameter type of at least one historical parameter and the parameter quantity of all historical parameters in each parameter list to determine whether the target parameter list exists in at least one parameter list;
[0172] When the target parameter list does not exist in at least one parameter list, a parameter value of each parameter is generated randomly according to the parameter type of each parameter;
[0173] In the case that there is a target parameter list in at least one parameter list, a parameter value of each parameter is determined according to the target parameter list and a parameter type of each parameter.
[0174] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0175] In one implementation, the processing module 52 is further configured to:
[0176] A parameter list is generated according to the parameter value of each parameter in the database operation method, the parameter type of each parameter, and the parameter quantity of all parameters, and the parameter list is stored.
[0177] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0178] In one implementation, the processing module 52 is specifically configured to:
[0179] For each parameter, determining whether to store the parameter value of the target historical parameter; wherein the parameter type of the target historical parameter is the same as the parameter type of the parameter;
[0180] In the case of determining to store the parameter value of the target historical parameter, determining the parameter value of the target historical parameter as the parameter value of the parameter;
[0181] In the case where it is determined that the parameter value of the target historical parameter is not stored, the parameter value of the parameter is generated in a random manner according to the parameter type of the parameter.
[0182] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0183] In one implementation, the processing module 52 is specifically configured to:
[0184] When the execution result is the first execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is adapted to the target database system;
[0185] When the execution result is the second execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is not compatible with the target database system.
[0186] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0187] In one implementation, the processing module 52 is specifically configured to:
[0188] Execute the target SQL statement and get the exception information;
[0189] When it is determined that the length of the abnormal information is greater than 0, determining that the execution result is the second execution result;
[0190] When it is determined that the length of the abnormal information is 0, the execution result is determined to be the first execution result.
[0191] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0192] In one implementation, the processing module 52 is further configured to:
[0193] When the execution result is the second execution result, the database operation method corresponding to the SQL statement template, the parameter value of each target parameter in the SQL statement template, the execution result, the adaptation result, and / or the exception information are stored and processed.
[0194] The device for determining the adaptation result provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0195] Figure 6 This is a structural diagram of a computing device provided by this application. Figure 6 As shown, the computing device 60 includes a processor 61 and a memory 62. The processor 61 is in communication connection with the memory 62, and the memory 62 is used to store computer-executable instructions; the processor 61 is configured to execute the technical solution in any of the above method embodiments by executing the computer-executable instructions stored in the memory 62.
[0196] Optionally, the memory 62 may be independent or integrated with the processor 61. Optionally, when the memory 62 is a device independent of the processor 61, the computing device 60 may further include: a bus 63 for connecting the above devices.
[0197] The computing device is used to execute the technical solution in any of the aforementioned method embodiments, and its implementation principle and technical effects are similar and will not be repeated here.
[0198] An embodiment of the present application also provides 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 technical solution provided by any of the aforementioned method embodiments.
[0199] An embodiment of the present application also provides a computer program product, including a computer program, which is used to implement the technical solution provided by the aforementioned method embodiment when executed by a processor.
[0200] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0201] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for determining an adaptation result, characterized in that: include: Acquire a mapper interface; the mapper interface includes at least one database operation method, and the database operation method includes at least one parameter; For each database operation method, determine the parameter type of each parameter in the database operation method, and generate a parameter value of each parameter in a random manner according to the parameter type of each parameter; According to the database operation method, determining at least one corresponding structured query language SQL statement template; The SQL statement template includes at least one target parameter; For each SQL statement template, determining the parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method; Obtain a target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template; The target SQL statement is executed to obtain an execution result, and an adaptation result of the SQL statement template is determined according to the execution result.
2. The method for determining the adaptation result according to claim 1, characterized in that: The generating a parameter value of each parameter in a random manner according to the parameter type of each parameter includes: Determining the number of parameters of all parameters in the database operation method; Get at least one parameter list; Compare the parameter type of each parameter and the parameter quantity of all parameters in the database operation method with the parameter type of at least one historical parameter and the parameter quantity of all historical parameters in each parameter list to determine whether a target parameter list exists in the at least one parameter list; In a case where the target parameter list does not exist in the at least one parameter list, generating a parameter value of each parameter in a random manner according to the parameter type of each parameter; In a case where the target parameter list exists in the at least one parameter list, a parameter value of each parameter is determined according to the target parameter list and a parameter type of each parameter.
3. The method for determining the adaptation result according to claim 2, characterized in that: Also includes: A parameter list is generated according to the parameter value of each parameter, the parameter type of each parameter, and the parameter quantity of all parameters in the database operation method, and the parameter list is stored.
4. The method for determining the adaptation result according to claim 1, characterized in that: The generating a parameter value of each parameter in a random manner according to the parameter type of each parameter includes: For each parameter, determining whether to store a parameter value of a target historical parameter; wherein the parameter type of the target historical parameter is the same as the parameter type of the parameter; In the case of determining to store the parameter value of the target historical parameter, determining the parameter value of the target historical parameter as the parameter value of the parameter; In the case where it is determined that the parameter value of the target historical parameter is not stored, the parameter value of the parameter is generated in a random manner according to the parameter type of the parameter.
5. The method for determining the adaptation result according to any one of claims 1 to 4, characterized in that: Determining the adaptation result of the SQL statement template according to the execution result includes: When the execution result is the first execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is adapted to the target database system; When the execution result is the second execution result, the adaptation result of the SQL statement template is that the format of the SQL statement template is not compatible with the target database system.
6. The method for determining the adaptation result according to claim 5, characterized in that: The executing the target SQL statement to obtain an execution result includes: Execute the target SQL statement and obtain exception information; In a case where it is determined that the length of the abnormal information is greater than 0, determining that the execution result is the second execution result; When it is determined that the length of the exception information is 0, the execution result is determined to be the first execution result.
7. The method for determining the adaptation result according to claim 6, characterized in that: Also includes: When the execution result is the second execution result, the database operation method corresponding to the SQL statement template, the parameter value of each target parameter in the SQL statement template, the execution result, the adaptation result, and / or the exception information are stored and processed.
8. A device for determining an adaptation result, characterized in that: include: An acquisition module, used for acquiring a mapper interface; the mapper interface includes at least one database operation method, and the database operation method includes at least one parameter; A processing module, used for determining, for each database operation method, a parameter type of each parameter in the database operation method, and generating a parameter value of each parameter in a random manner according to the parameter type of each parameter; The processing module is further used to determine at least one corresponding structured query language SQL statement template according to the database operation method; The SQL statement template includes at least one target parameter; The processing module is further used to determine, for each SQL statement template, a parameter value of each target parameter in the SQL statement template according to the parameter value of each parameter in the database operation method; The processing module is further used to obtain a target SQL statement according to the parameter value of each target parameter in the SQL statement template and the SQL statement template; The processing module is further used to execute the target SQL statement, obtain an execution result, and determine the adaptation result of the SQL statement template according to the execution result.
9. A computing device, characterized in that include: A processor, and a memory communicatively connected to the processor; The memory is used to store computer-executable instructions; The processor is used to execute the computer-executable instructions stored in the memory to implement the method for determining the adaptation result 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, and when the computer-executable instructions are executed by a processor, they are used to implement the method for determining the adaptation result according to any one of claims 1 to 7.
11. A computer program product, characterized in that The invention comprises a computer program, which is used to implement the method for determining the adaptation result according to any one of claims 1 to 7 when being executed by a processor.
Citation Information
Patent Citations
Test data generation method and device, storage medium and electronic equipment
CN113391992A
Java object generation method and system, computer equipment and readable storage medium
CN114138240A
Project migration processing method and device and electronic equipment
CN117093564A
Query statement checking method, device and equipment
CN117555922A
Database test method, apparatus and device, and computer readable storage medium
CN118113681A
