我有一个问题,为 SQL Server 2012 生成的种子输出此错误
[Illuminate\Database\QueryException]
SQLSTATE[22001]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Stri
ng or binary data would be truncated. (SQL: insert into [books] ([judul], [
pengarang], [dcc_code], [penerbit], [isbn], [tahun], [updated_at], [created
_at]) values (Problem solving with the programmable calculator : puzzle, ga
mes & simulation with math & science application, David L. Dunlop Thomas F
. Sigmund, 510.285, Prentice Hall, 0574213201, 1983, 2015-01-26 03:30:19.00
0, 2015-01-26 03:30:19.000))'
即使我已确保将架构设置为正确包含数据
Schema::create('books', function(Blueprint $table)
{
$table->engine="INNODB";
$table->increments('id');
$table->text('judul');
$table->string('pengarang', 200);
$table->string('dcc_code', 20);
$table->string('penerbit', 100);
$table->string('edisi', 100)->nullable();
$table->string('tahun', 10);
$table->string('isbn', 100)->nullable();
$table->string('book_image_name', 200)->nullable();
//Unique to Perpustakaan
$table->string('call_number', 100)->nullable();
$table->float('rating_cache')->default('0');
$table->integer('rating_count')->default('0');
$table->timestamps();
});
这是种子
Book::create(
array(
'judul' => "Problem solving with the programmable calculator : puzzle, games & simulation with math & science application",
'pengarang' => "David L. Dunlop Thomas F. Sigmund",
'dcc_code' => "510.285",
'penerbit' => "Prentice Hall",
'isbn' => "0574213201",
'tahun' => "1983"
)
);
任何帮助或提示将不胜感激!:)
根据@patricus 的提示,我发现 SQL Server 中生成的列只有 nvarchar(100) 而不是 nvarchar(300)。即使我已将类型更改为longText
in 迁移,生成的列仍然是nvarchar(100)