if I carry an AK and pick up a pistol
Another, and much better solution than querying the data table, is to give each gun a struct data to begin with. You then pick up the gun and it already has all the data, no need to fetch it from anywhere.
Elegant and efficient, you do it only once when the gun is spawned / placed on the map. And the player is using the data the gun carries.