[go: up one dir, main page]

CN111597164A - Database structure testing method, database structure testing device and terminal equipment - Google Patents

Database structure testing method, database structure testing device and terminal equipment Download PDF

Info

Publication number
CN111597164A
CN111597164A CN202010254298.4A CN202010254298A CN111597164A CN 111597164 A CN111597164 A CN 111597164A CN 202010254298 A CN202010254298 A CN 202010254298A CN 111597164 A CN111597164 A CN 111597164A
Authority
CN
China
Prior art keywords
database
data
field
end code
regular expression
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010254298.4A
Other languages
Chinese (zh)
Inventor
颜平平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Smart Technology Co Ltd
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN202010254298.4A priority Critical patent/CN111597164A/en
Publication of CN111597164A publication Critical patent/CN111597164A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application is applicable to the field of computers, and provides a database structure testing method, a database structure testing device and terminal equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining a regular expression to be detected in front-end codes, and converting the regular expression which accords with the language rules of the front-end codes into first database data which accords with the structured query language rules; extracting all second database fields matched with the first database fields and second data attributes corresponding to each second database field from a preset database; and comparing the first database data with each group of second database data to obtain a test result, wherein each group of second database data comprises a second database field and a second data attribute corresponding to the second database field. By the method, the efficiency of the database structure test and the accuracy of the test result can be effectively improved.

Description

数据库结构测试方法、数据库结构测试装置及终端设备Database structure testing method, database structure testing device and terminal equipment

技术领域technical field

本申请属于计算机领域,尤其涉及一种数据库结构测试方法、数据库结构测试装置及终端设备。The application belongs to the field of computers, and in particular relates to a database structure testing method, a database structure testing device and terminal equipment.

背景技术Background technique

在软件开发过程中,通常是在数据库中对数据的属性进行定义。例如:定义某个对话框中的数据属性为数值。由于前端开发人员对数据属性的关注度不够,经常会出现前端获取的数据属性与数据库定义的数据属性不同的情况。这就需要进行数据库结构测试。In the software development process, the attributes of the data are usually defined in the database. For example: define a data property in a dialog box as a value. Because front-end developers don't pay enough attention to data attributes, it often happens that the data attributes acquired by the front-end are different from those defined by the database. This requires database structure testing.

现有的数据库结构测试方法,通常是由测试人员进行穷举测试。例如:对某个对话框中的数据属性进行测试时,需要逐一输入不同属性的数据,以确认该对话框中的数据属性是否正确。这样的测试方法效率较低,并且由于测试人员的惯性思维,测试结果的准确率也较低。Existing database structure testing methods are usually exhaustive testing by testers. For example, when testing data attributes in a dialog box, it is necessary to input data of different attributes one by one to confirm whether the data attributes in the dialog box are correct. Such testing methods are less efficient, and due to the inertial thinking of the testers, the accuracy of the test results is also lower.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供了一种数据库结构测试方法、数据库结构测试装置及终端设备,可以解决现有的数据库结构测试方法的测试效率较低、测试结果准确率较低的问题。The embodiments of the present application provide a database structure testing method, a database structure testing device and a terminal device, which can solve the problems of low testing efficiency and low test result accuracy of the existing database structure testing method.

第一方面,本申请实施例提供了一种数据库结构测试方法,所述方法包括:In a first aspect, an embodiment of the present application provides a method for testing a database structure, the method comprising:

获取前端代码中待检测的正则表达式,并将符合前端代码语言规则的所述正则表达式转换为符合结构化查询语言规则的第一数据库数据,其中,所述第一数据库数据包括第一数据库字段以及所述第一数据库字段对应的第一数据属性;Obtain the regular expression to be detected in the front-end code, and convert the regular expression that conforms to the front-end code language rules into first database data that conforms to the structured query language rules, wherein the first database data includes the first database field and the first data attribute corresponding to the first database field;

从预设的数据库中提取与所述第一数据库字段匹配的所有第二数据库字段,以及每个第二数据库字段对应的第二数据属性;Extract all second database fields that match the first database fields, and second data attributes corresponding to each second database field from a preset database;

将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,其中,每组第二数据库数据中包括一个第二数据库字段以及与所述第二数据库字段对应的第二数据属性。Comparing the first database data with each group of second database data respectively to obtain a test result, wherein each group of second database data includes a second database field and second data corresponding to the second database field Attributes.

在第一方面的一种可能的实现方式中,所述将符合前端代码语言规则的所述正则化表达式转换为符合结构化查询语言规则的第一数据库数据,包括:In a possible implementation manner of the first aspect, converting the regularized expression conforming to the front-end code language rules into the first database data conforming to the structured query language rules includes:

获取所述前端代码语言规则与后端代码语言规则之间的预设映射关系,根据所述预设映射关系将所述正则表达式转换为符合所述后端代码语言规则的后端数据,所述后端数据包括至少一个后端代码字段和各个后端代码字段对应的第三数据属性;Obtain the preset mapping relationship between the front-end code language rules and the back-end code language rules, and convert the regular expression into back-end data that complies with the back-end code language rules according to the preset mapping relationship. The back-end data includes at least one back-end code field and a third data attribute corresponding to each back-end code field;

对于每个后端代码字段,将所述后端代码字段转换成符合结构化查询语言规则的第一数据库字段,并将所述第一数据库字段对应的第一数据属性设置为所述后端代码字段对应的第三数据属性。For each back-end code field, convert the back-end code field into a first database field that conforms to structured query language rules, and set the first data attribute corresponding to the first database field as the back-end code The third data attribute corresponding to the field.

在第一方面的一种可能的实现方式中,所述根据所述预设映射关系将所述正则表达式转换为符合所述后端代码语言规则的后端数据,包括:In a possible implementation manner of the first aspect, converting the regular expression into back-end data conforming to the back-end code language rule according to the preset mapping relationship includes:

根据所述预设映射关系识别出所述正则表达式对应的后端代码函数;Identifying the back-end code function corresponding to the regular expression according to the preset mapping relationship;

根据所述后端代码函数的定义规则,从所述后端代码函数中提取出所述后端代码字段和所述后端代码字段对应的第三数据属性,得到所述后端数据。According to the definition rule of the back-end code function, the back-end code field and the third data attribute corresponding to the back-end code field are extracted from the back-end code function to obtain the back-end data.

在第一方面的一种可能的实现方式中,所述将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,包括:In a possible implementation manner of the first aspect, the first database data is compared with each group of second database data respectively to obtain a test result, including:

对于每个第一数据库字段,在各组第二数据库数据中查找与所述第一数据库字段相同的第二数据库字段;For each first database field, search for the second database field that is the same as the first database field in each group of second database data;

若在各组第二数据库数据中未查找到与所述第一数据库字段相同的第二数据库字段,则生成第一异常结果,所述第一异常结果用于表示所述第二数据库数据中不存在与所述第一数据库字段相同的第二数据库字段;If the second database field that is the same as the first database field is not found in each group of second database data, a first abnormal result is generated, and the first abnormal result is used to indicate that the second database data does not contain the same second database field. there is a second database field identical to the first database field;

若在各组第二数据库数据中查找到与所述第一数据库字段相同的第二数据库字段,则根据第一集合以及第二集合生成测试结果,其中,所述第一集合为所述第一数据库字段对应的第一数据属性的集合,所述第二集合为与所述第一数据库字段相同的第二数据库字段对应的第二数据属性的集合。If a second database field that is the same as the first database field is found in each set of second database data, a test result is generated according to the first set and the second set, where the first set is the first set A set of first data attributes corresponding to a database field, and the second set is a set of second data attributes corresponding to a second database field that is the same as the first database field.

在第一方面的一种可能的实现方式中,所述根据第一集合以及第二集合生成测试结果,包括:In a possible implementation manner of the first aspect, the generating the test result according to the first set and the second set includes:

若所述第一集合与所述第二集合相同,则生成正常结果;if the first set is the same as the second set, generating a normal result;

若所述第一集合与所述第二集合无交集,则生成第二异常结果,所述第二异常结果用于提示用户重新进行测试;If there is no intersection between the first set and the second set, a second abnormal result is generated, and the second abnormal result is used to prompt the user to re-test;

若所述第一集合真包含所述第二集合,则生成第三异常结果,所述第三异常结果用于提示用户删除所述第一集合中不属于所述第二集合的第一数据属性;If the first set does contain the second set, a third abnormal result is generated, and the third abnormal result is used to prompt the user to delete the first data attribute in the first set that does not belong to the second set ;

若所述第二集合真包含所述第一集合,则生成第四异常结果,所述第四异常结果用于提示用户将所述第二集合中不属于所述第一集合的第二数据属性添加到所述第一集合中。If the second set does contain the first set, a fourth abnormal result is generated, where the fourth abnormal result is used to prompt the user to attribute the second data in the second set that does not belong to the first set added to the first set.

在第一方面的一种可能的实现方式中,所述方法还包括:In a possible implementation manner of the first aspect, the method further includes:

获取多组训练样本,其中,每组训练样本包括一个正则表达式和所述正则表达式对应的后端代码函数;Obtaining multiple sets of training samples, wherein each set of training samples includes a regular expression and a back-end code function corresponding to the regular expression;

利用所述多组训练样本对预设的神经网络进行训练,得到训练后的神经网络,并将所述训练后的神经网络作为所述预设映射关系。The preset neural network is trained by using the multiple sets of training samples to obtain a trained neural network, and the trained neural network is used as the preset mapping relationship.

在第一方面的一种可能的实现方式中,所述利用所述多组训练样本对预设的神经网络进行训练,包括:In a possible implementation manner of the first aspect, the training of the preset neural network by using the multiple sets of training samples includes:

对于每组训练样本,将所述训练样本中的正则表达式根据语法结构划分为至少一个语元,并将所述语元作为所述神经网络的输入。For each group of training samples, the regular expressions in the training samples are divided into at least one grammatical unit according to the grammatical structure, and the grammatical unit is used as the input of the neural network.

第二方面,本申请实施例提供了一种数据库结构测试装置,包括:In a second aspect, an embodiment of the present application provides a database structure testing device, including:

获取单元,用于获取前端代码中待检测的正则表达式,并将符合前端代码语言规则的所述正则表达式转换为符合结构化查询语言规则的第一数据库数据,其中,所述第一数据库数据包括第一数据库字段以及所述第一数据库字段对应的第一数据属性;an acquisition unit, configured to acquire the regular expression to be detected in the front-end code, and convert the regular expression that conforms to the front-end code language rules into first database data that conforms to the structured query language rules, wherein the first database The data includes a first database field and a first data attribute corresponding to the first database field;

提取单元,用于从预设的数据库中提取与所述第一数据库字段匹配的所有第二数据库字段,以及每个第二数据库字段对应的第二数据属性;an extraction unit, configured to extract from a preset database all second database fields matching the first database fields, and second data attributes corresponding to each second database field;

测试单元,用于将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,其中,每组第二数据库数据中包括一个第二数据库字段以及与所述第二数据库字段对应的第二数据属性。A test unit, configured to compare the first database data with each group of second database data respectively to obtain a test result, wherein each group of second database data includes a second database field and the second database field The corresponding second data attribute.

第三方面,本申请实施例提供了一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如上述第一方面中任一项所述的数据库结构测试方法。In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes all When the computer program is used, the database structure testing method according to any one of the above-mentioned first aspects is realized.

第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如上述第一方面中任一项所述的数据库结构测试方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, wherein, when the computer program is executed by a processor, the above-mentioned first aspect is implemented The database structure testing method of any one.

第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行上述第一方面中任一项所述的数据库结构测试方法。In a fifth aspect, an embodiment of the present application provides a computer program product that, when the computer program product runs on a terminal device, enables the terminal device to execute the database structure testing method described in any one of the first aspects above.

可以理解的是,上述第二方面至第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。It can be understood that, for the beneficial effects of the second aspect to the fifth aspect, reference may be made to the relevant description in the first aspect, which is not repeated here.

本申请实施例与现有技术相比存在的有益效果是:The beneficial effects that the embodiments of the present application have compared with the prior art are:

本申请实施例通过获取前端代码中待检测的正则表达式,并将符合前端代码语言规则的所述正则表达式转换为符合结构化查询语言规则的第一数据库数据,其中,所述第一数据库数据包括第一数据库字段以及所述第一数据库字段对应的第一数据属性;结构化查询语言是能够被数据库识别的语言,转换的实质是将前端代码转换为数据库语言;然后从预设的数据库中提取与所述第一数据库字段匹配的所有第二数据库字段,以及每个第二数据库字段对应的第二数据属性;将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,其中,每组第二数据库数据中包括一个第二数据库字段以及与所述第二数据库字段对应的第二数据属性。利用上述方法,将前端代码中和数据库中相匹配的字段对应的数据属性进行对比,通过客观的数据对比,避免了人工测试由于经验导致的错误结果,提高了测试结果的准确度。通过上述方法,能够对数据库结构进行自动测试,避免了采用穷举法测试的繁琐,提高了测试效率,同时提高了测试结果的准确率。In this embodiment of the present application, the regular expression to be detected in the front-end code is obtained, and the regular expression conforming to the front-end code language rules is converted into the first database data conforming to the structured query language rules, wherein the first database The data includes a first database field and a first data attribute corresponding to the first database field; the structured query language is a language that can be recognized by the database, and the essence of the conversion is to convert the front-end code into a database language; Extract all the second database fields that match the first database fields, and the second data attributes corresponding to each second database field; compare the first database data with each group of second database data respectively to obtain The test result, wherein each set of second database data includes a second database field and a second data attribute corresponding to the second database field. Using the above method, the data attributes corresponding to the matching fields in the front-end code and the database are compared, and through objective data comparison, the wrong results caused by manual testing due to experience are avoided, and the accuracy of the test results is improved. Through the above method, the database structure can be automatically tested, the tediousness of the exhaustive method test is avoided, the test efficiency is improved, and the accuracy of the test result is improved at the same time.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only for the present application. In some embodiments, for those of ordinary skill in the art, other drawings can also be obtained according to these drawings without any creative effort.

图1是本申请一实施例提供的数据库系统的示意图;1 is a schematic diagram of a database system provided by an embodiment of the present application;

图2是本申请一实施例提供的数据库结构测试方法的流程示意图;2 is a schematic flowchart of a database structure testing method provided by an embodiment of the present application;

图3是本申请一实施例提供的预设字典建立方法的流程示意图;3 is a schematic flowchart of a method for establishing a preset dictionary provided by an embodiment of the present application;

图4是本申请一实施例提供的数据库结构测试装置的结构示意图;4 is a schematic structural diagram of a database structure testing device provided by an embodiment of the present application;

图5是本申请一实施例提供的终端设备的结构示意图。FIG. 5 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.

具体实施方式Detailed ways

以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, for the purpose of illustration rather than limitation, specific details such as a specific system structure and technology are set forth in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It is to be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described feature, integer, step, operation, element and/or component, but does not exclude one or more other The presence or addition of features, integers, steps, operations, elements, components and/or sets thereof.

如在本申请说明书和所附权利要求书中所使用的那样,术语“若”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。As used in the specification of this application and the appended claims, the term "if" may be contextually interpreted as "when" or "once" or "in response to determining" or "in response to detecting ".

另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, in the description of the specification of the present application and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and should not be construed as indicating or implying relative importance.

在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。References in this specification to "one embodiment" or "some embodiments" and the like mean that a particular feature, structure or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in other embodiments," etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean "one or more but not all embodiments" unless specifically emphasized otherwise.

先介绍本申请实施例提供的数据库结构测试方法的一个应用场景。参见图1,为本申请实施例提供的数据库系统的示意图。如图所示,数据库系统可以包括:数据库服务器101和数据库102。数据库服务器利用本申请实施例提供的数据库结构测试方法对数据库结构进行测试。具体的,数据库服务器获取前端代码中待检测的正则表达式,将正则表达式转换为能够被数据库识别的第一数据库数据;并从数据库中提取与第一数据库数据对应的第二数据库数据,然后将第一数据库数据和第二数据库数据进行对比,得到测试结果。First, an application scenario of the database structure testing method provided by the embodiment of the present application is introduced. Referring to FIG. 1 , it is a schematic diagram of a database system according to an embodiment of the present application. As shown in the figure, the database system may include: a database server 101 and a database 102 . The database server tests the database structure by using the database structure testing method provided in the embodiment of the present application. Specifically, the database server obtains the regular expression to be detected in the front-end code, converts the regular expression into the first database data that can be recognized by the database; and extracts the second database data corresponding to the first database data from the database, and then The first database data and the second database data are compared to obtain a test result.

在实际应用中,数据库服务器也可以分开部署为前端服务器和后端服务器。前端服务器通过接口与后端服务器通信连接,后端服务器与数据库进行通信连接。此种情况下,本申请实施例提供的数据库结构测试方法中,通过前端服务器获取前端代码中待检测的正则表达式,将正则表达式根据预设映射关系转换为能够被后端服务器识别的后端数据,并将后端数据发送给后端服务器;然后通过后端服务器将后端数据转换为能够被数据库识别的第一数据库数据,从数据库中提取与第一数据库数据对应的第二数据库数据,并将第一数据库数据和第二数据库数据进行对比,得到测试结果。In practical applications, the database server can also be deployed separately as a front-end server and a back-end server. The front-end server communicates with the back-end server through the interface, and the back-end server communicates with the database. In this case, in the database structure testing method provided by the embodiment of the present application, the regular expression to be detected in the front-end code is obtained through the front-end server, and the regular expression is converted into a post-processing code that can be recognized by the back-end server according to the preset mapping relationship. The back-end data is sent to the back-end server; then the back-end data is converted into the first database data that can be recognized by the database through the back-end server, and the second database data corresponding to the first database data is extracted from the database. , and compare the first database data with the second database data to obtain the test result.

参见图2,为本申请一实施例提供的数据库结构测试方法的流程示意图。如图2所示,所述方法可以包括:Referring to FIG. 2 , it is a schematic flowchart of a database structure testing method according to an embodiment of the present application. As shown in Figure 2, the method may include:

S201,获取前端代码中待检测的正则表达式,并将符合前端代码语言规则的所述正则表达式转换为符合结构化查询语言规则的第一数据库数据。S201: Acquire a regular expression to be detected in the front-end code, and convert the regular expression conforming to the front-end code language rules into first database data conforming to the structured query language rules.

其中,所述第一数据库数据包括第一数据库字段以及所述第一数据库字段对应的第一数据属性。The first database data includes a first database field and a first data attribute corresponding to the first database field.

示例性的,假设第一数据库数据为(phone,number),其中,“phone”为第一数据库字段,“number”为第一数据属性。即第一数据属性用于限定第一数据库字段的数据结构。Exemplarily, it is assumed that the first database data is (phone, number), where "phone" is the first database field, and "number" is the first data attribute. That is, the first data attribute is used to define the data structure of the first database field.

正则表达式是由一个字符序列形成的搜索模式,利用该字符序列能够描述、匹配一系列符合某个句法规则的字符串,换句话说,正则表达式能够描述字符串中字符组合的模式。例如,a and b表示包含a和b两个字符的字符串,“database”就是一个符合该正则表达式的搜索结果。A regular expression is a search pattern formed by a sequence of characters, which can be used to describe and match a series of strings that conform to a certain syntactic rule. In other words, a regular expression can describe a pattern of character combinations in a string. For example, a and b means a string containing two characters a and b, and "database" is a search result that matches the regular expression.

当在文本中搜索数据时,可以用搜索模式来描述你要查询的内容。正则表达式通常用于前端页面。When searching for data in text, you can use search patterns to describe what you are looking for. Regular expressions are often used in front-end pages.

步骤S201中,正则表达式实质为前端代码,通常前端代码使用的语音为Javascrip。第一数据库数据为SQL数据,即符合结构化查询语言规则的数据。由于前端代码语言和数据库语言不同,因此不能直接将两者进行对比,需要将两者转换为相同的语言之后,再进行对比。In step S201, the regular expression is essentially a front-end code, and usually the voice used by the front-end code is Javascript. The first database data is SQL data, that is, data conforming to the rules of structured query language. Since the front-end code language and database language are different, it is not possible to directly compare the two. It is necessary to convert the two into the same language before comparing.

在实际应用中,可以将正则表达式先转换为JSON格式的数据,再将JSON格式的数据转换为SQL数据(即结构化查询语言)。这种转换方法需要编写转换代码,对于不同的正则表达式,则需要重新编写或修改转换代码,换句话说,每一个正则表达式都需要对应一套转换代码,这种方法使得转换过程较繁琐,转换效率较低。In practical applications, the regular expression can be converted into JSON-formatted data first, and then the JSON-formatted data can be converted into SQL data (ie, structured query language). This conversion method needs to write conversion code. For different regular expressions, you need to rewrite or modify the conversion code. In other words, each regular expression needs to correspond to a set of conversion codes, which makes the conversion process more complicated. , the conversion efficiency is low.

在一个实施例中,步骤S201,所述将符合前端代码语言规则的所述正则化表达式转换为符合结构化查询语言规则的第一数据库数据,包括:In one embodiment, in step S201, converting the regularized expression conforming to the front-end code language rules into first database data conforming to the structured query language rules includes:

S11,获取所述前端代码语言规则与后端代码语言规则之间的预设映射关系,根据所述预设映射关系将所述正则表达式转换为符合所述后端代码语言规则的后端数据,所述后端数据包括至少一个后端代码字段和各个后端代码字段对应的第三数据属性。S11: Acquire a preset mapping relationship between the front-end code language rules and the back-end code language rules, and convert the regular expression into back-end data conforming to the back-end code language rules according to the preset mapping relationship , the back-end data includes at least one back-end code field and a third data attribute corresponding to each back-end code field.

预设映射关系可以预先建立,这样,在需要转换数据时,根据预设映射关系,可以快速地查找到与某个正则表达式对应的后端数据,提高了转换效率。The preset mapping relationship can be established in advance, so that when data needs to be converted, back-end data corresponding to a regular expression can be quickly found according to the preset mapping relationship, which improves the conversion efficiency.

将正则表达式转换成后端数据,实际是将前端代码转换成后端代码的过程。因为前端代码通常用JavaScript,而后端代码通常用C++。Converting regular expressions into back-end data is actually the process of converting front-end code into back-end code. Because the front-end code is usually in JavaScript, and the back-end code is usually in C++.

S12,对于每个后端代码字段,将所述后端代码字段转换成符合结构化查询语言规则的第一数据库字段,并将所述第一数据库字段对应的第一数据属性设置为所述后端代码字段对应的第三数据属性。S12, for each back-end code field, convert the back-end code field into a first database field that complies with the structured query language rules, and set the first data attribute corresponding to the first database field to the back-end code field The third data attribute corresponding to the terminal code field.

因为数据库是基于结构化查询语言(简称SQL)的,所以将后端代码字段转译成第一数据库字段,实际是后端代码转换成能数据库语言的过程。Because the database is based on Structured Query Language (SQL for short), translating the back-end code field into the first database field is actually a process of converting the back-end code into a database language.

实际应用中,还有一种可能是,后端代码字段的表述和第一数据库字段的表述不同,例如,后端代码字段为“mobil”,对应的第一数据库字段为“phone”。它们所表达的意思都是手机,但是表述方式不同,这种情况下也需要进行转换的。In practical applications, there is another possibility that the expression of the back-end code field is different from that of the first database field. For example, the back-end code field is "mobil", and the corresponding first database field is "phone". The meanings they express are all mobile phones, but the expressions are different, and conversions are also required in this case.

在一个实施例中,步骤S11,所述根据所述预设映射关系将所述正则表达式转换为符合所述后端代码语言规则的后端数据,包括:In one embodiment, step S11, converting the regular expression into back-end data conforming to the back-end code language rule according to the preset mapping relationship includes:

S111,根据所述预设映射关系识别出所述正则表达式对应的后端代码函数。S111: Identify a back-end code function corresponding to the regular expression according to the preset mapping relationship.

S112,根据所述后端代码函数的定义规则,从所述后端代码函数中提取出所述后端代码字段和所述后端代码字段对应的第三数据属性,得到所述后端数据。S112, according to the definition rule of the back-end code function, extract the back-end code field and the third data attribute corresponding to the back-end code field from the back-end code function to obtain the back-end data.

示例性的,假设后端代码函数为set(a,b),该函数的定义规则为将a的属性设置为b。根据该函数的定义规则,提取出的后端代码字段为a,第三数据属性为b。需要说明的是,这里只是为了解释从后端代码函数中提取后端数据过程,并不做具体限定。Exemplarily, it is assumed that the back-end code function is set(a, b), and the definition rule of this function is to set the attribute of a to b. According to the definition rules of this function, the extracted back-end code field is a, and the third data attribute is b. It should be noted that this is only to explain the process of extracting back-end data from back-end code functions, and does not make any specific restrictions.

由于后端代码函数的定义规则是不变的,且为公知的,因此,得到了后端代码函数即可得到后端代码函数中的变量(即后端代码字段)和属性(即第三数据属性)。Since the definition rules of the back-end code functions are invariable and well known, the variables (that is, the back-end code fields) and attributes (that is, the third data) in the back-end code functions can be obtained by obtaining the back-end code functions. Attributes).

S202,从预设的数据库中提取与所述第一数据库字段匹配的所有第二数据库字段,以及每个第二数据库字段对应的第二数据属性。S202: Extract all second database fields matching the first database fields and second data attributes corresponding to each second database field from a preset database.

本申请实施例中预设的数据库是指与执行本申请实施例中的数据库结构测试方法的数据库服务器对应的数据库。The database preset in the embodiment of the present application refers to a database corresponding to the database server that executes the database structure testing method in the embodiment of the present application.

每个第一数据库字段可能与多个第二数据库字段匹配。这里的匹配,可以是指第一数据库字段与第二数据库字段完全相同,也可以指第一数据库字段与第二数据库字段部分相同。示例性的,假设第一数据库字段为“name”,数据库中与“name”匹配的有“name_number”、“name_length”、“name”等多个第二数据库字段,其中,“name_number”和“name_length”是与第一数据库字段部分相同的第二数据库字段。Each first database field may match multiple second database fields. The matching here may mean that the first database field is completely the same as the second database field, or it may mean that the first database field and the second database field are partially identical. Exemplarily, assuming that the first database field is "name", there are multiple second database fields such as "name_number", "name_length", and "name" that match "name" in the database, wherein "name_number" and "name_length" ” is a second database field that is partially identical to the first database field.

S203,将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果。S203, comparing the first database data with each group of second database data respectively to obtain a test result.

其中,每组第二数据库数据中包括一个第二数据库字段以及与所述第二数据库字段对应的第二数据属性。Wherein, each set of second database data includes a second database field and a second data attribute corresponding to the second database field.

在一个实施例中,步骤S203,所述将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,包括:In one embodiment, in step S203, the first database data is compared with each group of second database data respectively to obtain a test result, including:

S21,对于每个第一数据库字段,在各组第二数据库数据中查找与所述第一数据库字段相同的第二数据库字段。S21. For each first database field, search for a second database field that is the same as the first database field in each group of second database data.

这里的相同是指第一数据库字段与第二数据库字段完全相同。由于可能存在多个与第一数据库字段匹配的第二数据库字段,但进行比对时,实际是比对两个完全相同的字段的属性。因此,首先需要找到与第一数据库字段完全相同的第二数据库字段。如上述示例中,与“name”对应的第二字段有“name_number”、“name_length”、“name”等,相同的只有第二字段“name”。The same here means that the first database field is exactly the same as the second database field. Since there may be multiple second database fields that match the first database field, when comparing, the attributes of two identical fields are actually compared. Therefore, it is first necessary to find a second database field that is identical to the first database field. As in the above example, the second field corresponding to "name" includes "name_number", "name_length", "name", etc., and only the second field "name" is the same.

S22,若在各组第二数据库数据中未查找到与所述第一数据库字段相同的第二数据库字段,则生成第一异常结果,所述第一异常结果用于表示所述第二数据库数据中不存在与所述第一数据库字段相同的第二数据库字段。S22, if the second database field that is the same as the first database field is not found in each group of second database data, generate a first abnormal result, where the first abnormal result is used to represent the second database data There is no second database field that is the same as the first database field.

S23,若在各组第二数据库数据中查找到与所述第一数据库字段相同的第二数据库字段,则根据第一集合以及第二集合生成测试结果,其中,所述第一集合为所述第一数据库字段对应的第一数据属性的集合,所述第二集合为与所述第一数据库字段相同的第二数据库字段对应的第二数据属性的集合。S23, if a second database field that is the same as the first database field is found in each group of second database data, generate a test result according to the first set and the second set, wherein the first set is the A set of first data attributes corresponding to a first database field, and the second set is a set of second data attributes corresponding to a second database field that is the same as the first database field.

在一个实施例中,步骤S23,根据第一集合以及第二集合生成测试结果,包括:In one embodiment, step S23, generating test results according to the first set and the second set, including:

S231,若所述第一集合与所述第二集合相同,则生成正常结果。S231, if the first set is the same as the second set, generate a normal result.

第一集合与第二集合相同是指,在第一集合中可以找到第二集合中的每个第二数据属性,且第二集合中也可以找到第一集合中的每个第一数据属性。此时,说明前端定义的属性和数据库定义的属性是一致的。The fact that the first set is the same as the second set means that each second data attribute in the second set can be found in the first set, and each first data attribute in the first set can also be found in the second set. At this point, it means that the attributes defined by the front end are consistent with the attributes defined by the database.

S232,若所述第一集合与所述第二集合无交集,则生成第二异常结果,所述第二异常结果用于提示用户重新进行测试。S232, if the first set and the second set have no intersection, generate a second abnormal result, where the second abnormal result is used to prompt the user to re-test.

这种情况表示前端定义的属性和数据库定义的属性完全不同。此时,可能是前面步骤S201-S202执行错误导致的,也可能是数据库结构本身存在问题。这种情况下,可以提示用户重新执行步骤S201-S202。This situation means that the properties defined by the front end and the properties defined by the database are completely different. At this time, it may be caused by an error in the execution of the previous steps S201-S202, or there may be a problem with the database structure itself. In this case, the user may be prompted to perform steps S201-S202 again.

S233,若所述第一集合真包含所述第二集合,则生成第三异常结果,所述第三异常结果用于提示用户删除所述第一集合中不属于所述第二集合的第一数据属性。S233, if the first set really includes the second set, generate a third abnormal result, where the third abnormal result is used to prompt the user to delete the first set in the first set that does not belong to the second set data attributes.

此种情况,说明前端定义的属性超出了数据库定义的范围。In this case, the attributes defined by the front end are beyond the scope defined by the database.

S234,若所述第二集合真包含所述第一集合,则生成第四异常结果,所述第四异常结果用于提示用户将所述第二集合中不属于所述第一集合的第二数据属性添加到所述第一集合中。S234, if the second set really includes the first set, generate a fourth abnormal result, where the fourth abnormal result is used to prompt the user to assign the second set that does not belong to the first set in the second set A data attribute is added to the first set.

此种情况,说明前端定义的属性不完整。In this case, the attributes defined by the front-end are incomplete.

本申请实施例通过获取前端代码中待检测的正则表达式,并将符合前端代码语言规则的所述正则表达式转换为符合结构化查询语言规则的第一数据库数据,其中,所述第一数据库数据包括第一数据库字段以及所述第一数据库字段对应的第一数据属性;结构化查询语言是能够被数据库识别的语言,转换的实质是将前端代码转换为数据库语言;然后从预设的数据库中提取与所述第一数据库字段匹配的所有第二数据库字段,以及每个第二数据库字段对应的第二数据属性;将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,其中,每组第二数据库数据中包括一个第二数据库字段以及与所述第二数据库字段对应的第二数据属性。利用上述方法,将前端代码中和数据库中相匹配的字段对应的数据属性进行对比,通过客观的数据对比,避免了人工测试由于经验导致的错误结果,提高了测试结果的准确度。通过上述方法,能够对数据库结构进行自动测试,避免了采用穷举法测试的繁琐,提高了测试效率,同时提高了测试结果的准确率。In this embodiment of the present application, the regular expression to be detected in the front-end code is obtained, and the regular expression conforming to the front-end code language rules is converted into the first database data conforming to the structured query language rules, wherein the first database The data includes a first database field and a first data attribute corresponding to the first database field; the structured query language is a language that can be recognized by the database, and the essence of the conversion is to convert the front-end code into a database language; Extract all the second database fields that match the first database fields, and the second data attributes corresponding to each second database field; compare the first database data with each group of second database data respectively to obtain The test result, wherein each set of second database data includes a second database field and a second data attribute corresponding to the second database field. Using the above method, the data attributes corresponding to the matching fields in the front-end code and the database are compared, and through objective data comparison, the wrong results caused by manual testing due to experience are avoided, and the accuracy of the test results is improved. Through the above method, the database structure can be automatically tested, the tediousness of the exhaustive method test is avoided, the test efficiency is improved, and the accuracy of the test result is improved at the same time.

参见图3,为本申请实施例提供的预设字典建立方法的流程示意图。Referring to FIG. 3 , it is a schematic flowchart of a method for establishing a preset dictionary according to an embodiment of the present application.

作为本申请的一个实施例,预设映射关系可以是训练后的神经网络。因为在代码开发过程中,前端代码语言具有一定的规则,后端代码语言也具有一定的规则,因此可以预先建立前端代码语言规则与后端代码语言规则之间的映射关系。正则表达式实则为前端代码,后端代码函数属于后端代码,利用预先建立的映射关系就可以较快、较准确地查找到正则表达式对应的后端代码函数。As an embodiment of the present application, the preset mapping relationship may be a trained neural network. Because in the process of code development, the front-end code language has certain rules, and the back-end code language also has certain rules, so the mapping relationship between the front-end code language rules and the back-end code language rules can be established in advance. The regular expression is actually the front-end code, and the back-end code function belongs to the back-end code. Using the pre-established mapping relationship, the back-end code function corresponding to the regular expression can be found quickly and accurately.

如图3所示,预设字典的建立方法可以包括:As shown in Figure 3, the method for establishing the preset dictionary may include:

S301,获取多组训练样本,其中,每组训练样本包括一个正则表达式和所述正则表达式对应的后端代码函数。S301: Acquire multiple sets of training samples, wherein each set of training samples includes a regular expression and a back-end code function corresponding to the regular expression.

S302,利用所述多组训练样本对预设的神经网络进行训练,得到训练后的神经网络,并将所述训练后的神经网络作为所述预设映射关系。S302, using the multiple sets of training samples to train a preset neural network to obtain a trained neural network, and using the trained neural network as the preset mapping relationship.

可选的,对于每组训练样本,可以将所述训练样本中的正则表达式根据语法结构划分为至少一个语元,并将所述语元作为所述神经网络的输入,进行训练。Optionally, for each group of training samples, the regular expression in the training samples may be divided into at least one grammatical unit according to the grammatical structure, and the grammatical unit may be used as the input of the neural network for training.

示例性的,假设一个正则化表达式A and B可以拆分为3个语元,分别为“A”、“and”和“B”,将这3个语元作为神经网络的输入。Exemplarily, it is assumed that a regularized expression A and B can be split into 3 grammatical units, namely "A", "and" and "B", and these 3 grammatical units are used as the input of the neural network.

利用训练样本对神经网络进行训练,如果某个训练样本对应的神经网络的输出结果为该训练样本对应的后端代码函数,说明识别正确,否则识别错误。当识别正确率达到预设值时,训练结束。Use the training samples to train the neural network. If the output result of the neural network corresponding to a training sample is the back-end code function corresponding to the training sample, it means that the recognition is correct, otherwise the recognition is wrong. When the recognition accuracy reaches the preset value, the training ends.

在本实施例中,将正则化表达式划分为语元之后,再进行神经网络的训练,实际是在寻找语元之间的组合关系,进一步的,再确定组合关系对应的后端代码函数。换句话说,哪些语元组合在一起可以识别得到什么样后端代码函数。In this embodiment, after the regularized expression is divided into grammatical elements, the neural network is trained, which is actually to find the combination relationship between the grammatical elements, and further, to determine the back-end code function corresponding to the combination relationship. In other words, which lemmas are grouped together to identify what backend code functions result.

示例性的,正则化表达式“手机and数字”和正则化表达式“手机and数值”的神经网络识别结果可能相似,因为这两个正则化表达式的搜索模式是一样的。假设这两个正则化表达式对应的后端代码函数都是set(a,b)(其中,a为“and”前面的内容,即“手机”,b为“and”后边的内容,即“数字”或“数值”),那么他们的神经网络识别结果是一致的。也就是说,不管内容如何变,函数主体架构是一样的。如果出现一个新的正则化表达式“手机and字符”,它的搜索模式和前两个是一样的,也就是说他们的后端函数主体架构是一样的,那么对应的神经网络识别结果也会是set(a,b)。需要说明的是,上述示例只用于解释正则表达式与后端代码函数之间的对应关系,并不用于具体限定正则表达式和后端代码函数的形式、含义等等。Exemplarily, the neural network recognition results of the regularized expression "mobile phone and number" and the regularized expression "mobile phone and number" may be similar because the search patterns of the two regularized expressions are the same. Assume that the back-end code functions corresponding to these two regular expressions are set(a, b) (where a is the content before "and", that is, "mobile phone", and b is the content after "and", that is, " number" or "numerical value"), then their neural network recognition results are consistent. That is to say, no matter how the content changes, the structure of the function body is the same. If a new regular expression "mobile phone and character" appears, its search mode is the same as the previous two, that is to say, their back-end function main structure is the same, then the corresponding neural network recognition result will also be is set(a,b). It should be noted that the above examples are only used to explain the correspondence between regular expressions and back-end code functions, and are not used to specifically limit the forms, meanings, etc. of regular expressions and back-end code functions.

本申请实施例通过多个训练样本对神经网络进行训练,即找到正则表达式与后端代码函数之间的映射关系;然后将训练后的神经网络作为预设映射关系,当获取到待检测到正则表达式后,能利用建立好的预设字典自动、快速、准确地得到对应的后端代码函数。通过上述方法,有效提高了数据库结构测试方法的效率。In the embodiment of the present application, the neural network is trained by using multiple training samples, that is, the mapping relationship between the regular expression and the back-end code function is found; then the trained neural network is used as the preset mapping relationship. After the regular expression, the corresponding back-end code function can be obtained automatically, quickly and accurately by using the established preset dictionary. Through the above method, the efficiency of the database structure testing method is effectively improved.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

对应于上文实施例所述的工作模式的切换方法,图4示出了本申请实施例提供的数据库结构测试装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the switching method of the working mode described in the above embodiment, FIG. 4 shows a structural block diagram of the database structure testing apparatus provided by the embodiment of the present application. For the convenience of description, only the part related to the embodiment of the present application is shown. .

参照图4,该装置4包括:4, the device 4 includes:

获取单元41,用于获取前端代码中待检测的正则表达式,并将符合前端代码语言规则的所述正则表达式转换为符合结构化查询语言规则的第一数据库数据,其中,所述第一数据库数据包括第一数据库字段以及所述第一数据库字段对应的第一数据属性。The obtaining unit 41 is used to obtain the regular expression to be detected in the front-end code, and convert the regular expression conforming to the front-end code language rules into first database data conforming to the structured query language rules, wherein the first The database data includes a first database field and a first data attribute corresponding to the first database field.

提取单元42,从预设的数据库中提取与所述第一数据库字段匹配的所有第二数据库字段,以及每个第二数据库字段对应的第二数据属性。The extracting unit 42 extracts all the second database fields matching the first database fields and the second data attributes corresponding to each second database field from the preset database.

测试单元43,用于将所述第一数据库数据分别和每组第二数据库数据进行对比,得到测试结果,其中,每组第二数据库数据中包括一个第二数据库字段以及与所述第二数据库字段对应的第二数据属性。The test unit 43 is configured to compare the first database data with each group of second database data respectively to obtain a test result, wherein each group of second database data includes a second database field and a The second data attribute corresponding to the field.

可选的,获取单元41包括:Optionally, the obtaining unit 41 includes:

第一转换模块,用于获取所述前端代码语言规则与后端代码语言规则之间的预设映射关系,根据所述预设映射关系将所述正则表达式转换为符合所述后端代码语言规则的后端数据,所述后端数据包括至少一个后端代码字段和各个后端代码字段对应的第三数据属性。a first conversion module, configured to obtain a preset mapping relationship between the front-end code language rules and the back-end code language rules, and convert the regular expression into a language that conforms to the back-end code according to the preset mapping relationship The back-end data of the rule, the back-end data includes at least one back-end code field and a third data attribute corresponding to each back-end code field.

第二转换模块,用于对于每个后端代码字段,将所述后端代码字段转换成符合结构化查询语言规则的第一数据库字段,并将所述第一数据库字段对应的第一数据属性设置为所述后端代码字段对应的第三数据属性。The second conversion module is configured to, for each back-end code field, convert the back-end code field into a first database field conforming to the rules of structured query language, and convert the first data attribute corresponding to the first database field Set to the third data attribute corresponding to the back-end code field.

可选的,所述第一转换模块包括:Optionally, the first conversion module includes:

识别子模块,用于根据所述预设映射关系识别出所述正则表达式对应的后端代码函数。The identification sub-module is configured to identify the back-end code function corresponding to the regular expression according to the preset mapping relationship.

提取子模块,用于根据所述后端代码函数的定义规则,从所述后端代码函数中提取出所述后端代码字段和所述后端代码字段对应的第三数据属性,得到所述后端数据。The extraction sub-module is configured to extract the back-end code field and the third data attribute corresponding to the back-end code field from the back-end code function according to the definition rule of the back-end code function, and obtain the backend data.

可选的,测试单元43包括:Optionally, the testing unit 43 includes:

查找模块,用于根据所述后端代码函数的定义规则,从所述后端代码函数中提取出所述后端代码字段和所述后端代码字段对应的第三数据属性,得到所述后端数据。The search module is configured to extract the back-end code field and the third data attribute corresponding to the back-end code field from the back-end code function according to the definition rule of the back-end code function, and obtain the back-end code field. end data.

第一结果模块,用于若在各组第二数据库数据中未查找到与所述第一数据库字段相同的第二数据库字段,则生成第一异常结果,所述第一异常结果用于表示所述第二数据库数据中不存在与所述第一数据库字段相同的第二数据库字段。The first result module is configured to generate a first abnormal result if the second database field that is the same as the first database field is not found in each group of second database data, and the first abnormal result is used to indicate all The second database field that is the same as the first database field does not exist in the second database data.

第二结果模块,用于若在各组第二数据库数据中查找到与所述第一数据库字段相同的第二数据库字段,则根据第一集合以及第二集合生成测试结果,其中,所述第一集合为所述第一数据库字段对应的第一数据属性的集合,所述第二集合为与所述第一数据库字段相同的第二数据库字段对应的第二数据属性的集合。The second result module is configured to generate a test result according to the first set and the second set if a second database field that is the same as the first database field is found in each set of second database data, wherein the first A set is a set of first data attributes corresponding to the first database field, and the second set is a set of second data attributes corresponding to a second database field that is the same as the first database field.

可选的,第二结果模块还用于若所述第一集合与所述第二集合相同,则生成正常结果;若所述第一集合与所述第二集合无交集,则生成第二异常结果,所述第二异常结果用于提示用户重新进行测试;若所述第一集合真包含所述第二集合,则生成第三异常结果,所述第三异常结果用于提示用户删除所述第一集合中不属于所述第二集合的第一数据属性;若所述第二集合真包含所述第一集合,则生成第四异常结果,所述第四异常结果用于提示用户将所述第二集合中不属于所述第一集合的第二数据属性添加到所述第一集合中。Optionally, the second result module is further configured to generate a normal result if the first set is the same as the second set; and generate a second exception if the first set and the second set have no intersection As a result, the second abnormal result is used to prompt the user to perform the test again; if the first set really includes the second set, a third abnormal result is generated, and the third abnormal result is used to prompt the user to delete the The first data attribute in the first set that does not belong to the second set; if the second set really contains the first set, a fourth abnormal result is generated, and the fourth abnormal result is used to prompt the user to A second data attribute in the second set that does not belong to the first set is added to the first set.

可选的,装置4还包括:Optionally, the device 4 further includes:

样本获取单元,用于获取多组训练样本,其中,每组训练样本包括一个正则表达式和所述正则表达式对应的后端代码函数。The sample acquisition unit is used for acquiring multiple sets of training samples, wherein each set of training samples includes a regular expression and a back-end code function corresponding to the regular expression.

训练单元,用于利用所述多组训练样本对预设的神经网络进行训练,得到训练后的神经网络,并将所述训练后的神经网络作为所述预设映射关系。A training unit, configured to train a preset neural network by using the multiple sets of training samples to obtain a trained neural network, and use the trained neural network as the preset mapping relationship.

可选的,训练单元还用于对于每组训练样本,将所述训练样本中的正则表达式根据语法结构划分为至少一个语元,并将所述语元作为所述神经网络的输入。Optionally, the training unit is further configured to, for each group of training samples, divide the regular expression in the training samples into at least one grammatical unit according to the grammatical structure, and use the grammatical unit as the input of the neural network.

需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information exchange, execution process and other contents between the above-mentioned devices/units are based on the same concept as the method embodiments of the present application. For specific functions and technical effects, please refer to the method embodiments section. It is not repeated here.

另外,图4所示的数据库结构测试装置可以是内置于现有的终端设备内的软件单元、硬件单元、或软硬结合的单元,也可以作为独立的挂件集成到所述终端设备中,还可以作为独立的终端设备存在。In addition, the database structure testing device shown in FIG. 4 can be a software unit, a hardware unit, or a unit combining software and hardware built into the existing terminal equipment, or can be integrated into the terminal equipment as an independent pendant, and also Can exist as an independent terminal device.

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. Module completion, that is, dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated in one processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit, and the above-mentioned integrated units may adopt hardware. It can also be realized in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing from each other, and are not used to limit the protection scope of the present application. For the specific working processes of the units and modules in the above-mentioned system, reference may be made to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

图5为本申请一实施例提供的终端设备的结构示意图。如图5所示,该实施例的终端设备5包括:至少一个处理器50(图5中仅示出一个)处理器、存储器51以及存储在所述存储器51中并可在所述至少一个处理器50上运行的计算机程序52,所述处理器50执行所述计算机程序52时实现上述任意各个方法实施例中的步骤。FIG. 5 is a schematic structural diagram of a terminal device according to an embodiment of the present application. As shown in FIG. 5 , the terminal device 5 in this embodiment includes: at least one processor 50 (only one is shown in FIG. 5 ), a processor, a memory 51 , and a processor stored in the memory 51 and can be processed in the at least one processor A computer program 52 running on the processor 50, the processor 50 implements the steps in any of the above method embodiments when the computer program 52 is executed.

该终端设备可包括,但不仅限于,处理器、存储器。本领域技术人员可以理解,图5仅仅是终端设备5的举例,并不构成对终端设备5的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that FIG. 5 is only an example of the terminal device 5, and does not constitute a limitation on the terminal device 5. It may include more or less components than the one shown, or combine some components, or different components , for example, may also include input and output devices, network access devices, and the like.

所称处理器50可以是中央处理单元(Central Processing Unit,CPU),该处理器50还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 50 may be a central processing unit (Central Processing Unit, CPU), and the processor 50 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSP), application specific integrated circuits (Application Specific Integrated Circuits) , ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

所述存储器51在一些实施例中可以是所述终端设备5的内部存储单元,例如终端设备5的硬盘或内存。所述存储器51在另一些实施例中也可以是所述终端设备5的外部存储设备,例如所述终端设备5上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器51还可以既包括所述终端设备5的内部存储单元也包括外部存储设备。所述存储器51用于存储操作系统、应用程序、引导装载程序(BootLoader)、数据以及其他程序等,例如所述计算机程序的程序代码等。所述存储器51还可以用于暂时地存储已经输出或者将要输出的数据。The memory 51 may be an internal storage unit of the terminal device 5 in some embodiments, such as a hard disk or a memory of the terminal device 5 . The memory 51 may also be an external storage device of the terminal device 5 in other embodiments, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash memory card (Flash Card), etc. Further, the memory 51 may also include both an internal storage unit of the terminal device 5 and an external storage device. The memory 51 is used to store an operating system, an application program, a boot loader (Boot Loader), data, and other programs, such as program codes of the computer program, and the like. The memory 51 can also be used to temporarily store data that has been output or will be output.

本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现可实现上述各个方法实施例中的步骤。Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the foregoing method embodiments can be implemented.

本申请实施例提供了一种计算机程序产品,当计算机程序产品在移动终端上运行时,使得移动终端执行时实现可实现上述各个方法实施例中的步骤。The embodiments of the present application provide a computer program product, when the computer program product runs on a mobile terminal, the steps in the foregoing method embodiments can be implemented when the mobile terminal executes the computer program product.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,RandomAccess Memory)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the present application realizes all or part of the processes in the methods of the above embodiments, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When executed by a processor, the steps of each of the above method embodiments can be implemented. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form, and the like. The computer-readable medium may include at least: any entity or device capable of carrying the computer program code to the photographing device/terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electrical carrier signal, telecommunication signal, and software distribution medium. For example, U disk, mobile hard disk, disk or CD, etc. In some jurisdictions, under legislation and patent practice, computer readable media may not be electrical carrier signals and telecommunications signals.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the foregoing embodiments, the description of each embodiment has its own emphasis. For parts that are not described or described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.

在本申请所提供的实施例中,应该理解到,所揭露的装置/网络设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/网络设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units. Or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the above-mentioned embodiments, those of ordinary skill in the art should understand that: it can still be used for the above-mentioned implementations. The technical solutions described in the examples are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions in the embodiments of the application, and should be included in the within the scope of protection of this application.

Claims (10)

1. A method for testing a database structure, the method comprising:
the method comprises the steps of obtaining a regular expression to be detected in front-end codes, and converting the regular expression which accords with a front-end code language rule into first database data which accords with a structured query language rule, wherein the first database data comprises first database fields and first data attributes corresponding to the first database fields;
extracting all second database fields matched with the first database fields and second data attributes corresponding to each second database field from a preset database;
and comparing the first database data with each group of second database data to obtain a test result, wherein each group of second database data comprises a second database field and a second data attribute corresponding to the second database field.
2. The database structure testing method of claim 1, wherein said converting the regularization expression that conforms to front end code language rules to first database data that conforms to structured query language rules comprises:
acquiring a preset mapping relation between the front-end code language rule and the back-end code language rule, and converting the regular expression into back-end data which accords with the back-end code language rule according to the preset mapping relation, wherein the back-end data comprises at least one back-end code field and third data attributes corresponding to each back-end code field;
for each back-end code field, converting the back-end code field into a first database field conforming to the structured query language rule, and setting a first data attribute corresponding to the first database field as a third data attribute corresponding to the back-end code field.
3. The database structure testing method of claim 2, wherein said transforming said regular expression into backend data according to said preset mapping relationship, said backend data conforming to said backend code language rules, comprises:
identifying a back-end code function corresponding to the regular expression according to the preset mapping relation;
and extracting the back-end code field and a third data attribute corresponding to the back-end code field from the back-end code function according to the definition rule of the back-end code function to obtain the back-end data.
4. The method for testing a database structure according to claim 2, wherein the comparing the first database data with each group of second database data to obtain the test result comprises:
for each first database field, searching a second database field identical to the first database field in each group of second database data;
if a second database field identical to the first database field is not found in each group of second database data, generating a first abnormal result, wherein the first abnormal result is used for indicating that no second database field identical to the first database field exists in the second database data;
if a second database field identical to the first database field is found in each group of second database data, generating a test result according to a first set and a second set, wherein the first set is a set of first data attributes corresponding to the first database field, and the second set is a set of second data attributes corresponding to the second database field identical to the first database field.
5. The database structure testing method of claim 4, wherein generating test results from the first set and the second set comprises:
if the first set is the same as the second set, generating a normal result;
if the first set and the second set are not intersected, generating a second abnormal result, wherein the second abnormal result is used for prompting the user to test again;
if the first set really comprises the second set, generating a third exception result, wherein the third exception result is used for prompting a user to delete a first data attribute which does not belong to the second set in the first set;
and if the second set really comprises the first set, generating a fourth abnormal result, wherein the fourth abnormal result is used for prompting a user to add a second data attribute which does not belong to the first set in the second set into the first set.
6. The database structure testing method of claim 2, wherein the method further comprises:
acquiring a plurality of groups of training samples, wherein each group of training samples comprises a regular expression and a back-end code function corresponding to the regular expression;
and training a preset neural network by using the plurality of groups of training samples to obtain the trained neural network, and taking the trained neural network as the preset mapping relation.
7. The database structure testing method of claim 6, wherein the training of the predetermined neural network using the plurality of sets of training samples comprises:
for each group of training samples, dividing the regular expression in the training samples into at least one speech element according to a grammatical structure, and taking the speech element as the input of the neural network.
8. A database structure testing apparatus, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a regular expression to be detected in front-end codes and converting the regular expression conforming to a language rule of the front-end codes into first database data conforming to a structured query language rule, and the first database data comprises first database fields and first data attributes corresponding to the first database fields;
the extraction unit is used for extracting all second database fields matched with the first database fields and second data attributes corresponding to each second database field from a preset database;
and the test unit is used for comparing the first database data with each group of second database data to obtain a test result, wherein each group of second database data comprises a second database field and a second data attribute corresponding to the second database field.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN202010254298.4A 2020-04-02 2020-04-02 Database structure testing method, database structure testing device and terminal equipment Pending CN111597164A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010254298.4A CN111597164A (en) 2020-04-02 2020-04-02 Database structure testing method, database structure testing device and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010254298.4A CN111597164A (en) 2020-04-02 2020-04-02 Database structure testing method, database structure testing device and terminal equipment

Publications (1)

Publication Number Publication Date
CN111597164A true CN111597164A (en) 2020-08-28

Family

ID=72185446

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010254298.4A Pending CN111597164A (en) 2020-04-02 2020-04-02 Database structure testing method, database structure testing device and terminal equipment

Country Status (1)

Country Link
CN (1) CN111597164A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656432A (en) * 2021-08-16 2021-11-16 工银科技有限公司 Data comparison method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109271326A (en) * 2018-11-28 2019-01-25 优刻得科技股份有限公司 Test method and its device, the equipment and storage medium of cloud database
WO2019165691A1 (en) * 2018-02-28 2019-09-06 平安科技(深圳)有限公司 Method, apparatus and device for automatically generating test case, and readable storage medium
CN110837471A (en) * 2019-11-06 2020-02-25 中国农业银行股份有限公司 Test method, test device, server and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019165691A1 (en) * 2018-02-28 2019-09-06 平安科技(深圳)有限公司 Method, apparatus and device for automatically generating test case, and readable storage medium
CN109271326A (en) * 2018-11-28 2019-01-25 优刻得科技股份有限公司 Test method and its device, the equipment and storage medium of cloud database
CN110837471A (en) * 2019-11-06 2020-02-25 中国农业银行股份有限公司 Test method, test device, server and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656432A (en) * 2021-08-16 2021-11-16 工银科技有限公司 Data comparison method and device

Similar Documents

Publication Publication Date Title
CN111177184A (en) Natural language-based structured query language conversion method and related equipment
CN114880523B (en) String processing method, device, electronic device and storage medium
CN110795069A (en) Code analysis method, intelligent terminal and computer readable storage medium
CN111401034B (en) Semantic analysis method, semantic analysis device and terminal for text
CN111177358B (en) Intention recognition method, server and storage medium
CN108268368A (en) A kind of method and apparatus for generating test case script
CN113961768B (en) Sensitive word detection method and device, computer equipment and storage medium
CN112749258A (en) Data searching method and device, electronic equipment and storage medium
CN111354354B (en) Training method, training device and terminal equipment based on semantic recognition
CN107741972A (en) Image search method, terminal device and storage medium
CN109144879B (en) Test analysis method and device
CN111782781A (en) A semantic analysis method, device, computer equipment and storage medium
CN108170708B (en) Vehicle entity identification method, electronic equipment, storage medium and system
CN119646016A (en) Data query method, device, electronic device, medium and program product
CN111611793A (en) Data processing method, device, equipment and storage medium
CN114118049B (en) Information acquisition methods, devices, electronic equipment and storage media
CN115543339A (en) Code conversion method and device, computer equipment and storage medium
CN111723192A (en) Code recommendation method and device
CN115062126A (en) Statement analysis method and device, electronic equipment and readable storage medium
CN112181924A (en) File conversion method, device, equipment and medium
CN111597164A (en) Database structure testing method, database structure testing device and terminal equipment
CN110335628B (en) Voice test method and device of intelligent equipment and electronic equipment
CN110471708B (en) Method and device for acquiring configuration items based on reusable components
CN114492439B (en) A system and method for improving the accuracy of public opinion warning using deep learning
CN117435189A (en) Test case analysis method, device, equipment and medium of financial system interface

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20200828

WD01 Invention patent application deemed withdrawn after publication