... はこのAPIに従う例です。あるクラスが以下のメソッドを実装している場合、そのクラスはクエリ式APIに従っていると言えます: as_sql ( compiler , connection ) ¶ 式の SQL フラグメントを生成します。タプル (sql, params) を返します。 sql は SQL 文字列で、 params はクエリ ... パラメータのリストまたはタプルです。 compiler は SQLCompiler オブジェクトで、他の式をコンパイルするための compile() メソッドを持っています。 connection はクエリの実行に ... 使用する接続です。 expression.as_sql() の呼び出しは通常正しくありません。 代わりに compiler.compile(expression) を使用する必要があります。 compiler.compile() メソッドは式のベンダ固有のメソッドの呼び出しを行います。 ... ... はこのAPIに従う例です。あるクラスが以下のメソッドを実装している場合、そのクラスはクエリ式APIに従っていると言えます: as_sql ( compiler , connection ) ¶ 式の SQL フラグメントを生成します。タプル (sql, params) を返します。 sql は SQL 文字列で、 params はクエリ ... パラメータのリストまたはタプルです。 compiler は SQLCompiler オブジェクトで、他の式をコンパイルするための compile() メソッドを持っています。 connection はクエリの実行に ... 使用する接続です。 expression.as_sql() の呼び出しは通常正しくありません。 代わりに compiler.compile(expression) を使用する必要があります。 compiler.compile() メソッドは式のベンダ固有のメソッドの呼び出しを行います。 ... ... させる必要があります。 from django.db.models import Lookup class NotEqual ( Lookup ): lookup_name = "ne" def as_sql ( self , compiler , connection ): lhs , lhs_params = self . process_lhs ( compiler , connection ) rhs , rhs_params = self . process_rhs ( co ... ならない制約は、文字列 __ を決して含んではならないということです。 We then need to define the as_sql method. This takes a SQLCompiler object, called compiler , and the active database connection. SQLCompiler objects are not documented, but the only thing w ... では、左辺は Author モデルの name フィールドへの参照で、右辺は 'Jack' です。 process_lhs と process_rhs を呼び出して、前述の compiler オブジェクトを使用してSQLに必要な値に変換します。これらのメソッドは、SQL とその SQL に補間されるパラメーターを含むタプルを ... ... させる必要があります。 from django.db.models import Lookup class NotEqual ( Lookup ): lookup_name = "ne" def as_sql ( self , compiler , connection ): lhs , lhs_params = self . process_lhs ( compiler , connection ) rhs , rhs_params = self . process_rhs ( co ... ならない制約は、文字列 __ を決して含んではならないということです。 We then need to define the as_sql method. This takes a SQLCompiler object, called compiler , and the active database connection. SQLCompiler objects are not documented, but the only thing w ... では、左辺は Author モデルの name フィールドへの参照で、右辺は 'Jack' です。 process_lhs と process_rhs を呼び出して、前述の compiler オブジェクトを使用してSQLに必要な値に変換します。これらのメソッドは、SQL とその SQL に補間されるパラメーターを含むタプルを ... ... 。この属性が設定されていて、関数が異なる数の式で呼び出された場合、 TypeError が発生します。デフォルトは None です。 as_sql ( compiler , connection , function = None , template = None , arg_joiner = None , ** extra_context ) [ソース] ¶ データベース関数の SQ ... きです。例えば: django/db/models/functions.py ¶ class ConcatPair ( Func ): ... function = "CONCAT" ... def as_mysql ( self , compiler , connection , ** extra_context ): return super () . as_sql ( compiler , connection , function = "CONCAT_WS" , template = ... ( query , allow_joins , reuse , summarize , for_save ) return c 次に、SQLを生成するメソッドを書きます: def as_sql ( self , compiler , connection , template = None ): sql_expressions , sql_params = [], [] for expression in self . expressions : sql , param ... ... 。この属性が設定されていて、関数が異なる数の式で呼び出された場合、 TypeError が発生します。デフォルトは None です。 as_sql ( compiler , connection , function = None , template = None , arg_joiner = None , ** extra_context ) [ソース] ¶ データベース関数の SQ ... きです。例えば: django/db/models/functions.py ¶ class ConcatPair ( Func ): ... function = "CONCAT" ... def as_mysql ( self , compiler , connection , ** extra_context ): return super () . as_sql ( compiler , connection , function = "CONCAT_WS" , template = ... ( query , allow_joins , reuse , summarize , for_save ) return c 次に、SQLを生成するメソッドを書きます: def as_sql ( self , compiler , connection , template = None ): sql_expressions , sql_params = [], [] for expression in self . expressions : sql , param ... ... suffix , and data_type_check_constraints attributes have moved from the DatabaseCreation class to DatabaseWrapper . The SQLCompiler.as_sql() method now takes a subquery parameter ( #24164 ). The BaseDatabaseOperations.date_interval_sql() method now only ... erride either method. Support for storages that do not accept this argument will be removed in Django 1.10. qn replaced by compiler ¶ In previous Django versions, various internal ORM methods (mostly as_sql methods) accepted a qn (for "quote name") argum ... erence to a function that quoted identifiers for sending to the database. In Django 1.8, that argument has been renamed to compiler and is now a full SQLCompiler instance. For backwards-compatibility, calling a SQLCompiler instance performs the same name ... ... igns_in_column_aliases feature flag is removed. The DatabaseOperations.binary_placeholder_sql() method now expects a query compiler as an extra positional argument and should return a two-elements tuple composed of an SQL format string and a tuple of ass ... e of associated parameters. This method should now expect to be provided expressions meant to be compiled via the provided compiler argument. The quote_name_unless_alias() method of SQLCompiler , the type of object passed as the compiler argument to the ... ... suffix , and data_type_check_constraints attributes have moved from the DatabaseCreation class to DatabaseWrapper . The SQLCompiler.as_sql() method now takes a subquery parameter ( #24164 ). The BaseDatabaseOperations.date_interval_sql() method now only ... erride either method. Support for storages that do not accept this argument will be removed in Django 1.10. qn replaced by compiler ¶ In previous Django versions, various internal ORM methods (mostly as_sql methods) accepted a qn (for "quote name") argum ... erence to a function that quoted identifiers for sending to the database. In Django 1.8, that argument has been renamed to compiler and is now a full SQLCompiler instance. For backwards-compatibility, calling a SQLCompiler instance performs the same name ... ... igns_in_column_aliases feature flag is removed. The DatabaseOperations.binary_placeholder_sql() method now expects a query compiler as an extra positional argument and should return a two-elements tuple composed of an SQL format string and a tuple of ass ... e of associated parameters. This method should now expect to be provided expressions meant to be compiled via the provided compiler argument. The quote_name_unless_alias() method of SQLCompiler , the type of object passed as the compiler argument to the ... 2026年10月08日