| 512 | return super().get_prep_lookup() |
| 513 | |
| 514 | def process_rhs(self, compiler, connection): |
| 515 | db_rhs = getattr(self.rhs, "_db", None) |
| 516 | if db_rhs is not None and db_rhs != connection.alias: |
| 517 | raise ValueError( |
| 518 | "Subqueries aren't allowed across different databases. Force " |
| 519 | "the inner query to be evaluated using `list(inner_query)`." |
| 520 | ) |
| 521 | |
| 522 | if self.rhs_is_direct_value(): |
| 523 | # Remove None from the list as NULL is never equal to anything. |
| 524 | try: |
| 525 | rhs = OrderedSet(self.rhs) |
| 526 | rhs.discard(None) |
| 527 | except TypeError: # Unhashable items in self.rhs |
| 528 | rhs = [r for r in self.rhs if r is not None] |
| 529 | |
| 530 | if not rhs: |
| 531 | raise EmptyResultSet |
| 532 | |
| 533 | # rhs should be an iterable; use batch_process_rhs() to |
| 534 | # prepare/transform those values. |
| 535 | sqls, sqls_params = self.batch_process_rhs(compiler, connection, rhs) |
| 536 | placeholder = "(" + ", ".join(sqls) + ")" |
| 537 | return (placeholder, sqls_params) |
| 538 | return super().process_rhs(compiler, connection) |
| 539 | |
| 540 | def get_rhs_op(self, connection, rhs): |
| 541 | return "IN %s" % rhs |