@@ -98,10 +98,7 @@ def get_text_clause(self) -> sqlalchemy.sql.expression.TextClause:
98
98
table_name = dialect .identifier_preparer .quote (table_name )
99
99
field_name = dialect .identifier_preparer .quote (field_name )
100
100
101
- return text (
102
- f"{ prefix } { table_name } "
103
- f".{ self ._get_field_name_direction_nulls (field_name = field_name )} "
104
- )
101
+ return text (f"{ prefix } { table_name } .{ self ._get_field_direction_nulls ()} " )
105
102
106
103
def _split_value_into_parts (self , order_str : str ) -> None :
107
104
if order_str .startswith ("-" ):
@@ -111,37 +108,33 @@ def _split_value_into_parts(self, order_str: str) -> None:
111
108
self .field_name = parts [- 1 ]
112
109
self .related_parts = parts [:- 1 ]
113
110
114
- def _generate_field_nulls_query (self , field_name : str , result : str ) -> str :
111
+ def _generate_field_nulls_query (self , result : str ) -> str : # pragma: no cover
115
112
"""
116
113
Generate the Final Query with handling mysql syntax for nulls value
117
114
118
- :param field_name: string name of this field for order
119
- :type field_name: str
120
115
:param result: query generated in previous stage without nulls value
121
116
:type result: str
122
117
:return: result of the final query by field name and direction and nulls value
123
118
:rtype: str
124
119
"""
125
120
126
121
if not self .is_mysql_bool :
127
- return result + f" nulls { self .nulls } " # pragma: no cover
122
+ return result + f" nulls { self .nulls } "
128
123
129
- condition : str = "not" if self .nulls == "first" else "" # pragma: no cover
130
- return f"{ field_name } is { condition } null, { result } " # pragma: no cover
124
+ condition : str = "not" if self .nulls == "first" else ""
125
+ return f"{ self . get_field_name_text () } is { condition } null, { result } "
131
126
132
- def _get_field_name_direction_nulls (self , field_name : str ) -> str :
127
+ def _get_field_direction_nulls (self ) -> str :
133
128
"""
134
129
Generate the Query of Order for this field name by direction and nulls value
135
130
136
- :param field_name: string name of this field for order
137
- :type field_name: str
138
131
:return: result of the query by field name and direction and nulls value
139
132
:rtype: str
140
133
"""
141
134
142
- result : str = f"{ field_name } { self .direction } "
135
+ result : str = f"{ self . get_field_name_text () } { self .direction } "
143
136
if self .nulls is not None :
144
- return self ._generate_field_nulls_query (field_name = field_name , result = result )
137
+ return self ._generate_field_nulls_query (result = result )
145
138
146
139
return result
147
140
0 commit comments