File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,20 +140,14 @@ def struct_options_statment(model: BaseModel,
140140 Returns:
141141 Select: Экземпляр запроса
142142 """
143- if one_to_many and many_to_many :
144- stmt = (Select (model )
145- .filter_by (** kwargs )
146- .options (selectinload (* one_to_many ))
147- .options (joinedload (* many_to_many )))
148- elif one_to_many :
149- stmt = (Select (model )
150- .filter_by (** kwargs )
151- .options (selectinload (* one_to_many )))
152- elif many_to_many :
153- stmt = (Select (model )
154- .filter_by (** kwargs )
155- .options (joinedload (* many_to_many )))
156- else :
157- stmt = (Select (model )
158- .filter_by (** kwargs ))
143+ stms_one_to_many = ([selectinload (join ) for join in one_to_many ]
144+ if one_to_many
145+ else list ())
146+ stmt_any_to_many = ([joinedload (join )for join in many_to_many ]
147+ if many_to_many
148+ else list ())
149+ stmt = (Select (model )
150+ .filter_by (** kwargs )
151+ .options (* stms_one_to_many )
152+ .options (* stmt_any_to_many ))
159153 return stmt
You can’t perform that action at this time.
0 commit comments