@@ -83,18 +83,20 @@ public function parseKey(Query $query, string|int|Raw $key, bool $strict = false
8383 // JSON字段支持
8484 [$ field , $ name ] = explode ('-> ' , $ key );
8585 $ key = '" ' . $ field . '" ' . '->> \'' . $ name . '\'' ;
86- } elseif (str_contains ($ key , '. ' )) {
87- [$ table , $ key ] = explode ('. ' , $ key , 2 );
86+ } else {
87+ if (str_contains ($ key , '. ' ) && !preg_match ('/[, \'\"\(\)`\s]/ ' , $ key )) {
88+ [$ table , $ key ] = explode ('. ' , $ key , 2 );
8889
89- $ alias = $ query ->getOption ('alias ' );
90+ $ alias = $ query ->getOption ('alias ' );
9091
91- if ('__TABLE__ ' == $ table ) {
92- $ table = $ query ->getOption ('table ' );
93- $ table = is_array ($ table ) ? array_shift ($ table ) : $ table ;
94- }
92+ if ('__TABLE__ ' == $ table ) {
93+ $ table = $ query ->getOption ('table ' );
94+ $ table = is_array ($ table ) ? array_shift ($ table ) : $ table ;
95+ }
9596
96- if (isset ($ alias [$ table ])) {
97- $ table = $ alias [$ table ];
97+ if (isset ($ alias [$ table ])) {
98+ $ table = $ alias [$ table ];
99+ }
98100 }
99101
100102 if ('* ' != $ key && !preg_match ('/[,\"\*\(\).\s]/ ' , $ key )) {
@@ -103,7 +105,11 @@ public function parseKey(Query $query, string|int|Raw $key, bool $strict = false
103105 }
104106
105107 if (isset ($ table )) {
106- $ key = $ table . '. ' . $ key ;
108+ if (str_contains ($ table , '. ' )) {
109+ $ table = str_replace ('. ' , '"." ' , $ table );
110+ }
111+
112+ $ key = '" ' . $ table . '". ' . $ key ;
107113 }
108114
109115 return $ key ;
0 commit comments