我有一个这样的模型:
class Article(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
class Meta:
db_table = 'article'
我写了查询:
articles = Article.objects.filter(title__iexact='hello world')
print(articles.query)
输出结果为:
SELECT ... FROM `article` WHERE `article`.`title` LIKE hello world
您可以看到iexact
已翻译为LIKE。但是django文档说它会翻译成ILIKE,谁错了?
顺便说一下:
我的mysql排序规则是utf8_bin。
mysql在ubuntu上提供服务。
代码在Windows上运行。
答案 0 :(得分:0)
文档说here,<item name="android:backgroundDimAmount">0.5</item>
的SQL等价物为private void Form1_Load(object sender, EventArgs e)
{
ActiveForm.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEscKeyPress);
//Hide the Form
this.Hide();
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
this.Size = new System.Drawing.Size(screenWidth, screenHeight);
this.Location = new System.Drawing.Point(screenLeft, screenTop);
//Create the Bitmap
//Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
// Screen.PrimaryScreen.Bounds.Height);
Bitmap printscreen = new Bitmap(SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height,
PixelFormat.Format32bppArgb);
//Create the Graphic Variable with screen Dimensions
Graphics graphics = Graphics.FromImage(printscreen as Image);
//Copy Image from the screen
graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
using (MemoryStream s = new MemoryStream())
{
//save graphic variable into memory
printscreen.Save(s, System.Drawing.Imaging.ImageFormat.Bmp);
pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
pictureBox1.Size = new System.Drawing.Size(this.Width, this.Height);
//set the picture box with temporary stream
pictureBox1.Image = Image.FromStream(s);
}
//this.Location = Screen.AllScreens[1].WorkingArea.Location;
this.Location = new System.Drawing.Point(screenLeft, screenTop);
//this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Show();
//Cross Cursor
Cursor = Cursors.Cross;
}
。它并没有说iexact
会在MySQL中转换为ILIKE
。这根本不可能。 MySQL没有iexact
。 ILIKE
已经不区分大小写了。
在我使用的PostgreSQL中,ILIKE
转换为:
LIKE
MySQL中iexact
和SELECT ... FROM "article" WHERE UPPER("article"."title"::text) = UPPER(hello world)
之间的区别如下:
exact
iexact