小编Ste*_*ley的帖子

什么可以解释"无效的存储块长度"错误?

我在Vagrant虚拟盒中的基本Ubuntu lucid32映像上运行带有Ruby 1.9.3p194的Rails(3.2.3)应用程序.虚拟盒正在Leopard上运行,因为它的价值.我正在尝试在应用程序中使用rubyzip来解压缩zip存档 - 2009_da_lmp.zip.直接使用rubyzip存储库中的示例代码,我可以确认我可以列出存档文件内容:

#f is the absolute path to 2009_da_lmp.zip (string)
Zip::ZipFile.open(f) { |zf| zf.entries[0] }  
 => 20090101_da_lmp.csv #that is indeed a file in the archive.
Run Code Online (Sandbox Code Playgroud)

使用存储库中示例中的更多代码,我尝试获取存档中的实际文件:

Zip::ZipInputStream.open(f) { |zis|
  entry = zis.get_next_entry
  print "first line of '#{entry.name}' (#{entry.size} bytes: ) "
  puts "'#{zis.gets.chomp}'" }

=> first line of '20090101_da_lmp.csv' (826610 bytes: ) Zlib::DataError: 
   invalid stored block lengths #and a long stack trace I can provide 
                                #if that might help
Run Code Online (Sandbox Code Playgroud)

Mac OS解压缩实用程序将存档解压缩.我想知道它是否是某种编码相关的东西(我的语言环境设置为en_US.UTF-8,因为在开发中使用PostgreSQL不那么痛苦),但我不知道如何判断是否是这种情况.我找不到任何可能导致此错误的信息.

ruby zlib rubyzip

5
推荐指数
1
解决办法
1万
查看次数

Repo.all 失败,因为我有自定义主键

我为没有字段的表生成并运行了迁移id(使用该字段league_id作为主键)。我确认迁移按预期进行(检查了 psql 中的数据库,该表确实没有id字段并且league_id是主键)。

当我运行时,Repo.all(League)出现以下错误:

13:01:14.962 [debug] QUERY ERROR source="leagues" db=2.8ms

SELECT l0."id", l0."league_id" FROM "leagues" AS l0 []

** (Postgrex.Error) ERROR 42703 (undefined_column): column l0.id does not exist

有没有办法告诉Repo.all/1没有 id 字段(除了手动构建SELECT *-type 查询之外?)

elixir ecto

1
推荐指数
1
解决办法
1417
查看次数

标签 统计

ecto ×1

elixir ×1

ruby ×1

rubyzip ×1

zlib ×1