This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 1f33ff642 fix: the length of the column (#4520)
1f33ff642 is described below

commit 1f33ff642e6c8c30d57de722f0b3b077af94208c
Author: Igor Izvekov <[email protected]>
AuthorDate: Tue Feb 28 04:48:12 2023 +0300

    fix: the length of the column (#4520)
    
    fix: the length of the column (#4520)
---
 backend/plugins/customize/service/service.go      |  2 +-
 backend/plugins/customize/service/service_test.go | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/backend/plugins/customize/service/service.go 
b/backend/plugins/customize/service/service.go
index 869492f13..50dc5a83a 100644
--- a/backend/plugins/customize/service/service.go
+++ b/backend/plugins/customize/service/service.go
@@ -40,7 +40,7 @@ type Service struct {
 }
 
 func NewService(dal dal.Dal) *Service {
-       return &Service{dal: dal, nameChecker: regexp.MustCompile(`^x_\w+`)}
+       return &Service{dal: dal, nameChecker: 
regexp.MustCompile(`^x_[a-zA-Z0-9_]{0,50}$`)}
 }
 
 // GetFields returns all the fields of the table
diff --git a/backend/plugins/customize/service/service_test.go 
b/backend/plugins/customize/service/service_test.go
index d3208cd02..8242e5f87 100644
--- a/backend/plugins/customize/service/service_test.go
+++ b/backend/plugins/customize/service/service_test.go
@@ -19,11 +19,12 @@ package service
 
 import (
        "regexp"
+       "strings"
        "testing"
 )
 
 func TestService_checkFieldName(t *testing.T) {
-       nameChecker := regexp.MustCompile(`^x_\w+`)
+       nameChecker := regexp.MustCompile(`^x_[a-zA-Z0-9_]{0,50}$`)
        tests := []struct {
                name string
                args string
@@ -44,6 +45,16 @@ func TestService_checkFieldName(t *testing.T) {
                        "x__",
                        true,
                },
+               {
+                       "issue #4519",
+                       "x_" + strings.Repeat("a", 50),
+                       true,
+               },
+               {
+                       "issue #4519",
+                       "x_" + strings.Repeat("a", 51),
+                       false,
+               },
                {
                        "",
                        "x_ space",

Reply via email to