I have a problem where the generated seed for SQL Server 2012 outputs this error
[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))'
Even though I've made sure I set my schema to contain the data correctly
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();
});
Here's the seed
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"
)
);
Any help or hint would be appreciated! :)
Per @patricus hint, I found out that the generated column in SQL Server is only nvarchar(100) rather than nvarchar(300). Even though I've changed the type into longText
in migrations, the generated column still is nvarchar(100)