请帮忙! 我想知道下面提到的原始oracle查询的内连接Queryset: -
从PubEv中选择PubC.component,PubC.comp_version,PubC.publish_id,PubEv.published_date 内联盟PubC 在PubC.publish_id = PubEv.publish_id 哪里 PubC.target_branch ='polaris_dev'和PubC.component ='aaa' 由PubEv.published_date desc;
命令django项目中提到的模型如下: -
class PubEv(models.Model):
vob = models.CharField(max_length=20)
target_branch = models.CharField(max_length=60)
publish_id = models.IntegerField(primary_key=True)
target_branch_label = models.CharField(max_length=50, blank=True, null=True)
main_release = models.CharField(max_length=10, blank=True, null=True)
published_by = models.CharField(max_length=16)
published_date = models.DateTimeField()
publish_ddts = models.CharField(max_length=10)
unpublished = models.CharField(max_length=1)
changeset = models.ForeignKey('CcChangesets')
class Meta:
managed = False
db_table = 'publish_events'
class PubC(models.Model):
publish_id = models.IntegerField(primary_key=True)
vob = models.CharField(max_length=20)
target_branch = models.CharField(max_length=60)
component = models.CharField(max_length=40)
comp_version = models.CharField(max_length=40)
class Meta:
managed = False
db_table = 'publish_contents'
答案 0 :(得分:0)
我不认为在Django ORM中可以做到这一点。如果你建立OneToOne
关系而不是试图将它们保持为无关的主键字段,你会好得多。